開源庫實現SwitchButton開關按鈕
阿新 • • 發佈:2019-02-04
實現效果圖:
(1)在biuld.gradle檔案中加入
compile 'com.github.zcweng:switch-button:[email protected]'
(2)新建xml檔案
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto"android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent">
<com.suke.widget.SwitchButton android:layout_width="0dp" android:layout_weight="0.8" android:layout_height="30dp" android:layout_gravity="center_vertical" app:sb_checked_color="@color/colorPrimaryDark" app:sb_show_indicator="false" app:sb_checked="true"/>
</LinearLayout>
寫完後視覺化介面沒顯示按鈕,在build裡clean一下專案即可。