设置组件不同状态下的背景颜色

deanyuancn
发布于 2021-1-17 11:48
浏览
0收藏

  今天来分享一下如何设置组件不同状态下的背景颜色,这里我定义了一个Ability,布局页面放了一个按钮和单选按钮代码如下

<?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">

    <RadioButton
        ohos:id="$+id:radChoose"
        ohos:height="50vp"
        ohos:width="match_content"
        ohos:text_size="30vp"
        ohos:background_element="gray"
        ohos:text="选我吧"/>
    <Button
        ohos:id="$+id:btnDisable"
        ohos:height="match_content"
        ohos:width="match_content"
        ohos:text="禁用"
        ohos:text_size="30vp"
        ohos:background_element="gray"/>
</DirectionalLayout>

已于2021-1-17 11:48:11修改
收藏
回复
举报
2条回复
按时间正序
/
按时间倒序
鸿蒙张荣超
鸿蒙张荣超

没看出来对应哪些不同的状态呢^_^

回复
2021-1-17 22:30:46
Tuer白晓明
Tuer白晓明

如果有逻辑代码的会让其他人更容易理解^_^。

回复
2021-1-18 09:44:13
回复
    相关推荐