先来看一下switchbutton的效果
第一步需要添加依赖
dependencies {
compile 'com.kyleduo.switchbutton:library:1.4.6'
}
然后就可以在布局文件中使用SwitchButton这个控件
<com.kyleduo.switchbutton.SwitchButton
android:id="@+id/switchbutton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:kswBackColor="#0f0"
app:kswTintColor="#00f"
app:kswTextOn="开"
app:kswTextOff="关"
/>