跳到主要内容

Switch开关按钮

说明

开关按钮

使用示例

<Switch android:layout_height="wrap_parent"
android:layout_width="match_parent"
android:tag="switch"
android:text="按钮"
android:textColor="#669999"
android:textSize="14dp"
android:gravity="center"
android:checked="true"

/>

属性说明

公有属性

请参考 公有属性

私有属性

属性名说明可选值
layout_weight子元素权重数字
当父级为LinearLayout的时候,子控件可以设置权重
gravity内部的控件对齐方式用法参考
top
bottom
left
right
center_vertical
fill_vertical
center_horizontal
fill_horizontal
center
fill
clip_vertical
clip_horizontal
checked是否选择true:选中 false:不选中
text文字字符串
textColor文字颜色16进制,例如#FFFFFF
textSize文字大小具体数字+dp