I have a custom selector to Thumb and Track Switch
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/bt_rules_box_control" android:state_enabled="false" />
<item android:drawable="@drawable/bt_rules_box_control" android:state_pressed="true" />
<item android:drawable="@drawable/bt_rules_box_control" android:state_checked="true" />
<item android:drawable="@drawable/bt_rules_box_control" />
</selector>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/bg_rules_box_control" android:state_enabled="false" />
<item android:drawable="@drawable/bg_rules_box_control" android:state_pressed="true" />
<item android:drawable="@drawable/bg_rules_box_control" android:state_checked="true" />
<item android:drawable="@drawable/bg_rules_box_control" />
</selector>
I want to get this Switch like result and put text ON/OFF

My question is how can i change the color of the ON / OFF text without changing the thumb image? The color ON / OFF text is white and the image color of the thumb is same. It confuses the two colors
You can set the text color to a color state list selector. Use the same states as before, but use android:color instead of android:drawable as the value for each state. Color StateList
Notice that this resource goes in res/color, not res/drawable
res/color/switch_text_selector.xml
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="#00000000" android:state_checked="true" />
<item android:color="#FFFFFFFF" />
</selector>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With