前言
Android中的Switch控件很使用,比如WiFi开关等。Switch可以提供切图,也可以自定义属性。本文就是主要介绍自定义。
记录一下,方便自己查阅和回顾。
正文
activity_main.xml
<Switch style="@style/Widget.AppCompat.CompoundButton.Switch" android:layout_width="200dp" android:layout_height="50dp" android:showText="true" android:textColor="@color/default_color_0" android:textOff="Off" android:textOn="On" android:textSize="@dimen/text_default_size" android:thumb="@drawable/switch_thumb_bg" android:track="@drawable/switch_track_bg" tools:ignore="UseSwitchCompatOrMaterialXml" />
drawable/switch_thumb_bg.xml drawable/switch_thumb_on_bg.xml drawable/switch_thumb_on_bg.xml drawable/switch_thumb_off_bg.xml
参考文章
《
© 版权声明