如何设置子元素在位置定位时的锚点?

如何设置子元素在位置定位时的锚点?

HarmonyOS
2024-07-28 09:12:55
浏览
收藏 0
回答 1
待解决
回答 1
按赞同
/
按时间
pumayze

在position的基础上进行偏移。postion({x:20,y:40})为相对于父元素左上角,向右偏移20,向下偏移40。markAnchor({x:10,y:30})相当于在postion的基础上,向左偏移10,向上偏移30.整体来看相当于向右偏移10,向下偏移10

Row() {
  Text().width(20)
    .height(20)
    .backgroundColor(Color.White)
    .position({ x: 20, y: 40 })
    .markAnchor({x:10,y:30})
}
.width(200)
.height(150)
.backgroundColor(Color.Orange)
分享
微博
QQ
微信
回复
2024-07-28 20:38:24
相关问题
如何获取元素位置和大小
1889浏览 • 1回复 待解决
Scroll组件展示位置如何调整
2015浏览 • 1回复 待解决
java中如何设置CommonDialog位置?
5033浏览 • 1回复 待解决
如何设置窗口背景颜色?
142浏览 • 1回复 待解决
如何设置自定义弹窗位置
1728浏览 • 1回复 待解决
Swiper组件如何设置导航点位置
1748浏览 • 1回复 待解决
怎么设置元素最大宽度最小宽度?
132浏览 • 1回复 待解决