- xml中使用
<Switch
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:switchMinWidth="@dimen/dp_50"
android:textOff=" "
android:textOn=" "
android:thumb="@drawable/switch_custom_thumb_selector"
android:track="@drawable/switch_custom_track_selector" />
2.switch_custom_thumb_selector.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/switch_custom_thumb_on" android:state_checked="true" />
<item android:drawable="@drawable/switch_custom_thumb_off" android:state_checked="false" />
</selector>
</