Change color of Switch in Android
As per this, (direct answer by BoD copy-paste):
You must not use
android:thumb
andandroid:track
, but instead,app:thumb
andapp:track
And you must add the following to the root of your xml document:xmlns:app="http://schemas.android.com/apk/res-auto"
Easiest way in Android Lollipop and above,
<style name="AppTheme" parent="MaterialTheme.Light"> ... <item name="android:colorControlActivated">@color/color_switch</item></style>
Try this:
switch_thumb.xml
<selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_enabled="false" android:drawable="@drawable/switch_thumb_holo_light" /> <item android:state_pressed="true" android:drawable="@drawable/switch_thumb_activated_holo_light" /> <item android:state_checked="true" android:drawable="@drawable/switch_thumb_activated_holo_light" /> <item android:drawable="@drawable/switch_thumb_holo_light" /> </selector>
In the layout of the switch:
android:thumb="@drawable/switch_thumb"