当前位置:网站首页>【FAQ】HarmonyOS ETS如何给组件设置边框
【FAQ】HarmonyOS ETS如何给组件设置边框
2022-08-10 17:45:00 【华为开发者论坛】
【问题描述】
如何给Text组件设置左上 右上 为圆角,现在的boder方法 只能一起设置4个角
【解决方案】
我们可以使用boder设置圆角,或者在text组件添加一个矩形的遮罩层
1、参考资料
2、代码运行
代码如下
import featureAbility from '@ohos.ability.featureAbility';@[email protected] Index { build() { Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { Text("border").width("100%").height(100).fontSize(50).textAlign(TextAlign.Center) Text("Z").width(100).height(100) .border({color:Color.Blue,radius:10})//todo 设置边框 .fontSize(50) .textAlign(TextAlign.Center) .backgroundColor(Color.Red) Text("设置两边圆角") .width("100%") .height(100) .fontSize(50) .textAlign(TextAlign.Center) Text('Z') .width(100) .height(100) .textAlign(TextAlign.Center) .fontSize(50) .backgroundColor(Color.Red) //todo 从Text组件左上角开始 // todo 当Rect的width和height和Text组件的width和height大小相等时候 刚好覆盖text组件 .mask(new Rect({width: 100, height: 150}).fill(Color.White).radius(20)) } .width('100%') .height('100%') }}
欲了解更多更全技术文章,欢迎访问https://developer.huawei.com/consumer/cn/forum/?ha_source=zzh
边栏推荐
猜你喜欢
随机推荐
想玩转监控神器Prometheus吗?
Making Pre-trained Language Models Better Few-Shot Learners
去除富文本标签样式
【2011】【论文笔记】用THz-TDS观察水树——
Toronto Research Chemicals农药检测丨甲硫威
Xilinx FPGA收发器参考时钟设计应用
AVFrame相关api内存管理
Toronto Research Chemicals BTK抑制剂丨ACP-5197
「软件架构」10种常见的软件架构模式
H3C_堆叠(IRF)及链路聚合在项目中的综合应用
CAS客户端对接
机器人控制器编程实践指导书旧版-实践四 步进电机(执行器)
FFmpeg extract H264 nalu from the mp4
Toronto Research Chemicals农药检测丨Naled-d6
R语言拟合ARIMA模型:使用forecast包中的auto.arima函数自动搜索最佳参数组合、模型阶数(p,d,q)、如果已知阶数则直接使用arima函数构建模型(order参数指定阶数)
【接入指南 之 直接接入】手把手教你快速上手接入HONOR Connect平台(上)
Selenium - 如何操作鼠标进行悬停、右击、双击、拖拽?
机器人控制器编程实践指导书旧版-实践八 机器人综合设计
兼具外观、性能、屏幕!华硕灵耀X 14火热抢购中
Splitting and merging long markdown documents








