
回复
Switch是一种用于显示开关状态的UI控件.
https://gitee.com/hspbc/harmonyos_demos/tree/master/switchDemo
属性名 | 用途 |
---|---|
ohos:width | 设置控件宽度,可设置为:match_parent(和父控件一样),match_content(按照内容自动伸缩),设置固定值(如200vp) |
ohos:height | 设置控件高度,可设置为:match_parent(和父控件一样),match_content(按照内容自动伸缩),设置固定值(如200vp) |
ohos:layout_alignment | 在父控件内对齐方式,可选值:left:居左;start:居左;center:居中;right:居右;end:居右 |
ohos:background_element | 设置背景,可以是色值(如#FF0000)或图片等 |
ohos:visibility | 可选值: visible(显示), invisible(隐藏,但是仍占据UI空间),hide(隐藏,且不占UI空间) |
ohos:text_size | 设置字号 |
ohos:text_color | 设置文字颜色,样例:ohos:text_color=“#FF0000”, |
ohos:text_state_on | 设置选中时文字,样例:ohos:text_state_on=“ON” |
ohos:text_state_off | 设置未选中时文字,样例: ohos:text_state_off=“OFF” |
ohos:marked | 设置是否选中,可选值:true:选中;false:未选中 |
更多属性及实际效果,可以在开发工具里自行体验.