`
Switch是切换单个设置开/关两种状态的组件。我们体验效果如下。
显示效果:
滑动按钮
代码如下:
布局中
<?xml version="1.0" encoding="utf-8"?>
<DirectionalLayout
xmlns:ohos="http://schemas.huawei.com/res/ohos"
ohos:height="match_parent"
ohos:width="match_parent"
ohos:orientation="vertical">
<Switch
ohos:id="$+id:btn_switch"
ohos:height="30vp"
ohos:width="60vp"
ohos:top_margin="40px"
ohos:left_margin="400px"
ohos:text_state_off="OFF"
ohos:text_state_on="ON"/>
</DirectionalLayout>
完整源码地址:
`