系统自带的SwitchCompat,效果是这样的
然后通过选择器改变形状及颜色显示:selector_smart_house_switch.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="true" android:drawable="@drawable/kai2x"/>
<item android:state_checked="false" android:drawable="@drawable/guan2x"/>
</selector>
<android.support.v7.widget.SwitchCompat
android:id="@+id/sc_gold"
android:layout_width="@dimen/dp_46"
android:layout_height="@dimen/dp_26"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="16dp"
android:background="@drawable/selector_smart_house_switch"
android:theme="@style/scstyle"
app:showText="false"
app:splitTrack="false"
app:thumbTint="#00000000"
app:trackTint="#00000000" />
之后的效果成这样: