如何设置子元素相对父元素左上角的偏移量?

如何设置子元素相对父元素左上角的偏移量?

HarmonyOS
2024-07-28 09:10:36
浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
janux

使用position设置子元素相对于父元素的相对位置。设置该属性不参与父容器布局

Row() {
  Text().width(20)
    .height(20)
    .backgroundColor(Color.White)
    .position({x:10,y:40})
}
.width(200)
.height(150)
.backgroundColor(Color.Orange)
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.

分享
微博
QQ
微信
回复
2024-07-28 20:31:32
相关问题
HarmonyOS 元素阴影被子元素覆盖
529浏览 • 1回复 待解决
如何获取Scroll组件的当前滚动偏移量
2965浏览 • 1回复 待解决