Styling the custom switch in android

95 views Asked by At

I am trying to create a listview with switches. It is working; but not as how i expected it to be. The text ON/OFF is written inside the circle(slider) and not behind it which looks awkward. I cannot find a way on how to put the text behind the slider and i tried searching but it seems that no one is experiencing this problem aside from me.

Also, is there a way where i can edit the custom switch or am i obliged to use android:background like what others are doing base on my research. (I am avoiding to use background because i am not good at Photoshop).

Thank you in advance!

1

There are 1 answers

0
Anil Meenugu On

You can have 9 patch images for switch

<Switch
            android:id="@+id/switch_bg2"
            android:layout_width="92dp"
            android:layout_height="24dp"
            android:checked="true"
            android:focusable="false"
            android:textOff="O"
            android:textOn="I"
            android:thumb="@drawable/switch_thumb"
            android:track="@drawable/switch_bg"
            android:typeface="sans" />