ArkUI中的Margin类,如何分别取出Margin中的left,top,right,bottom属性的值

HarmonyOS
2024-12-24 15:53:57
1219浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
Excelsior_abit

关于margin属性设置参考文档

https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/ts-universal-attributes-size-V5#示例

这里是简易demo

@Entry
@Component
struct Index {
  @State message: string = 'Hello World';

  build() {
    RelativeContainer() {
      Text(this.message)
        .id('HelloWorld')
        .fontSize(50)
        .fontWeight(FontWeight.Bold)
        .margin({
          top:70,
          left:20,
          right:5,
          bottom:5
        })
        .border({ width: 5, color: 0x317AF7, radius: 10, style: BorderStyle.Dotted })
    }
    .height('100%')
    .width('100%')
  }
}
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
分享
微博
QQ
微信
回复
2024-12-24 18:11:23


相关问题
HarmonyOS Button 无法添加margin left right
1204浏览 • 1回复 待解决
HarmonyOS rightpadding和margin不生效
1579浏览 • 1回复 待解决
span组件使用margin属性失效
2582浏览 • 1回复 待解决
HarmonyOS 属性默认问题
1077浏览 • 1回复 待解决
LeftTop为什么不生效?
1664浏览 • 1回复 待解决
HarmonyOS margin不生效
1442浏览 • 1回复 待解决
HarmonyOS 设置margin无效
593浏览 • 1回复 待解决
HarmonyOS margin不生效问题
1062浏览 • 1回复 待解决
HarmonyOS 怎么给属性赋默认
2190浏览 • 1回复 待解决