先看效果
布局文件
最新更新加入了sb_前缀避免将来产生冲突,并改进了一下源码
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center"
>
<com.laitech.widget.SwitchButton
android:layout_width="100dp"
android:layout_height="50dp"
/>
<com.laitech.widget.SwitchButton
android:layout_marginTop="20dp"
android:layout_width="100dp"
android:layout_height="50dp"
app:sb_onColor="#ea2df4"
app:sb_check="true"
/>
<com.laitech.widget.SwitchButton
android:layout_marginTop="20dp"
android:layout_width="100dp"
android:layout_height="50dp"
app:sb_btnRatio="0.5"
/>
<com.laitech.widget.SwitchButton
android:layout_marginTop="20dp"
android:layout_width="100dp"
android:layout_height="50dp"
app:sb_barRatio="0.6"
/>
<com.laitech.widget.SwitchButton
android:layout_marginTop="20dp"
android:layout_width="100dp"
android:layout_height="50dp"
app:sb_barRatio="0.6"
app:sb_btnRatio="0"
app:sb_check="true"
app:sb_onColor="#ea2df4"
app:sb_offColor="#8f5959"
app:sb_btnColor="#ef4779"
app:sb_animDuration="300"
/>
</LinearLayout>