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

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

阅读 515
1 个回答

关于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%')
  }
}
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进