buttom样式怎么添加?

BUTTON样式很丰富,什么圆角的,直角的,圆形的等等,这些样式要怎么添加进来?还有编写格式要求?

<Button
        ohos:id="$+id:button"
        ohos:width="match_content"
        ohos:height="match_content"
        ohos:left_margin="88vp"
        ohos:right_margin="88vp"
        ohos:top_margin="70vp"
        ohos:text_size="19fp"
        ohos:text="点我"
        ohos:background_element="$graphic:color_blue_element" //按照网上提示,编译报错
        ohos:text_color="white"
        />
HarmonyOS
2020-10-20 10:24:37
浏览
收藏 0
回答 2
待解决
回答 2
按赞同
/
按时间
charlesc
1

在app目录下resources/base文件目录下创建graphic目录

如果要实现圆角等 需要编写xml文件 例如新建bg_common_unpress_btn.xml 如下

<?xml version="1.0" encoding="UTF-8" ?>

<shape xmlns:ohos="http://schemas.huawei.com/res/ohos"

       ohos:shape="rectangle">

    <corners

            ohos:radius="100"/>

    <solid

            ohos:color="#2E9EED"/>

</shape>

shape类型与android的shape类型相似。

使用方式为

ohos:background_element="$graphic:bg_common_unpress_btn"

 

 

分享
微博
QQ
微信
回复
2020-10-20 10:43:54
bugouhen
1

结帖!!!!!!!!!!!!!

妙啊,加了后飘红问题完美解决

分享
微博
QQ
微信
回复
2020-10-20 11:28:32
相关问题
鸿蒙怎么实现UI控件样式复用 ?
5690浏览 • 3回复 待解决
服务中心添加卡片怎么添加
4419浏览 • 1回复 待解决
开发鸿蒙怎么使用less来设计样式
4999浏览 • 1回复 待解决
Image 上怎么添加文字?
1001浏览 • 1回复 待解决
ets怎么实现动态添加组件?
1463浏览 • 1回复 待解决
listContainer怎么通过addComponent添加布局
6170浏览 • 1回复 待解决
Mysql怎么添加外键有知道的吗?
348浏览 • 1回复 待解决
@Extend的样式如何跨组件共享?
617浏览 • 1回复 待解决
鸿蒙组件toast自定义样式
6500浏览 • 1回复 待解决
JS swiper 怎么像list一样动态添加item?
4558浏览 • 1回复 待解决
如何按照条件完成样式的链式调用
142浏览 • 1回复 待解决
何设置组件不同状态下的样式
279浏览 • 1回复 待解决
如何设置组件不同状态下的样式
248浏览 • 1回复 待解决
如何自定义Video组件控制栏样式
287浏览 • 1回复 待解决
文本组件是否支持分段设置字体样式
225浏览 • 1回复 待解决