
上QQ阅读APP看本书,新人免费读10天
设备和账号都新为新人
2.2.5 PositionLayout
这种布局文件相对比较简单。在这种布局中,组件通过(x, y)坐标来确定具体的位置。左上角坐标为(0,0),横向为x轴,竖向为y轴,坐标数值沿各自方向逐渐增大。可以通过 PositionLayout的ohos:position_x和ohos:position_y属性来确定组件绘制的起始坐标。
下面实现一个PositionLayout,在其中添加三个组件。


页面的预览效果如图2-29所示。
这张图有 A、B、C 三个组件依次摆放,这三个组件都由 ohos:position_x和 ohos:position_y属性来指定组件开始绘制的坐标点,且后摆放的B组件遮挡住了先摆放的A组件,如果组件之间重叠,那么后摆放的组件会在先摆放的组件的上层。C组件没有和A、B组件重叠,这不影响它根据具体的坐标点确定起始位置。