harmonyos开发-PositionLayout布局
在PositionLayout中,子组件通过指定准确的x/y坐标值在屏幕上显示。(0, 0)为左上角;当向下或向右移动时,坐标值变大;允许组件之间互相重叠。
绝对布局
PositionLayout以坐标的形式控制组件的显示位置,允许组件相互重叠。
position_x
水平方向坐标
position_y
垂直方向坐标
<?xml version="1.0" encoding="utf-8"?>
<PositionLayout
ohos:width="match_parent"
ohos:height="match_parent"
xmlns:ohos="http://schemas.huawei.com/res/ohos">
<Text
ohos:height="match_content"
ohos:position_y="150vp"
ohos:text="你好,世界!"
ohos:text_size="40fp"
ohos:position_x="20vp"
ohos:width="match_content"/>
<Text
ohos:height="match_content"
ohos:position_y="210vp"
ohos:text="你好,鸿蒙!"
ohos:text_color="#e10b2b"
ohos:text_size="40fp"
ohos:position_x="60vp"
ohos:width="match_content"/>
<Text
ohos:height="match_content"
ohos:position_y="270vp"
ohos:text="你好,Java!"
ohos:text_size="40fp"
ohos:position_x="15vp"
ohos:width="match_content"/>
</PositionLayout>