Switch是一种用于显示开关状态的UI控件.
基础样例1.普通开关效果图代码Switchandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:text="我是Switch"/2.设置字号效果图代码
Switchandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:text="我是20号字体的Switch"android:textSize="20sp"/3.设置颜色效果图代码
Switchandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:text="我是红色的Switch"android:textColor="#FF"/4.设置加粗效果图代码
Switchandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:text="我是加粗的Switch"android:textStyle="bold"/5.设置选中效果图代码
Switchandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:checked="true"android:text="我是被选中的Switch"/5.设置开关按钮文字效果图代码
Switchandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:showText="true"android:text="开关上显示文字"android:textOff="已关闭"android:textOn="已打开"/基础样例完整源代码