小编 Th*_*der的帖子

How can I create custom switches in android with text on both side of switch's track an in thumb?

How can I design custom switch in android as like in below image:

状态 1

When it's turned on, it needs to look like this

状态 2

I also need to show toggle animation effects while switching between two categories. How Can I achieve it? Is there any 3rd party SDK or libraries available? Currently I have designed it with a custom linear layout as like this:

my_layout.xml:

 <LinearLayout
                android:id="@+id/customSliderLayout"
                android:layout_width="@dimen/_200sdp"
                android:layout_height="@dimen/_39sdp"
                android:layout_centerInParent="true"
                android:orientation="horizontal"
                android:weightSum="2"
                android:background="@drawable/oval_layout_bg"
                android:layout_centerHorizontal="true">

                <Button
                    android:id="@+id/userBtn"
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:textAllCaps="false"
                    android:text="@string/toggle_user" …
Run Code Online (Sandbox Code Playgroud)

android native android-switch

12
推荐指数
2
解决办法
6309
查看次数

标签 统计

android ×1

android-switch ×1

native ×1