一個自定義的帶有動畫的滑動開關控件:CoolSwitch

jopen 9年前發布 | 18K 次閱讀 Android開發 移動開發 CoolSwitch

介紹:

CoolSwitch是Android的一個自定義開關視圖,針對Android版本>2.3。提供很棒的顯示動畫。

運行效果:

使用說明:

將switch控件添加到布局中,同時指定disabled和enabled兩種狀態下的view,如果任意一個沒有指定,將不會有動畫。

<com.serchinastico.coolswitch.CoolSwitch
    android:id="@+id/cool_switch_foo"
    android:layout_height="35dp"
    android:layout_width="60dp"
    coolswitch:disabledView="@id/disabled_view_foo"
    coolswitch:enabledView="@id/enabled_view_foo"/>


將動畫view包裹在TargetFrameLayout或者TargetLinearLayout中:

<com.serchinastico.coolswitch.TargetFrameLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">

    <LinearLayout
            android:id="@+id/disabled_view_foo"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="#FF0000"/>

    <LinearLayout
            android:id="@+id/enabled_view_foo"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="#00FF00"/>

</com.serchinastico.coolswitch.TargetFrameLayout>

項目主頁:http://www.baiduhome.net/lib/view/home/1427961213037

 本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
 轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
 本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!