文章40 | 阅读 20971 | 点赞0
<?xml version="1.0" encoding="utf-8"?>
<PositionLayout
xmlns:ohos="http://schemas.huawei.com/res/ohos"
ohos:id="$+id:position"
ohos:height="match_parent"
ohos:width="300vp"
ohos:background_element="#3387CEFA">
<Text
ohos:id="$+id:position_text_1"
ohos:height="50vp"
ohos:width="200vp"
ohos:background_element="#9987CEFA"
ohos:position_x="50vp"
ohos:position_y="8vp"
ohos:text="Title"
ohos:text_alignment="center"
ohos:text_size="20fp"/>
<Text
ohos:id="$+id:position_text_2"
ohos:height="200vp"
ohos:width="200vp"
ohos:background_element="#9987CEFA"
ohos:position_x="8vp"
ohos:position_y="64vp"
ohos:text="Content"
ohos:text_alignment="center"
ohos:text_size="20fp"/>
<Text
ohos:id="$+id:position_text_3"
ohos:height="200vp"
ohos:width="200vp"
ohos:background_element="#9987CEFA"
ohos:position_x="92vp"
ohos:position_y="188vp"
ohos:text="Content"
ohos:text_alignment="center"
ohos:text_size="20fp"/>
</PositionLayout>
Text title = (Text)findComponentById(ResourceTable.Id_position_text_1);
Text content1 = (Text)findComponentById(ResourceTable.Id_position_text_2);
Text content2 = (Text)findComponentById(ResourceTable.Id_position_text_3);
title.setPosition(vp2px(50), vp2px(8));
content1.setPosition(vp2px(8), vp2px(64));
content2.setPosition(vp2px(92), vp2px(188));
private int vp2px(float vp) {
return AttrHelper.vp2px(vp,this);
}
<?xml version="1.0" encoding="utf-8"?>
<PositionLayout
...>
...
<Text
ohos:id="$+id:position_text_4"
ohos:height="120vp"
ohos:width="120vp"
ohos:background_element="#9987CEFA"
ohos:position_x="212vp"
ohos:position_y="64vp"
ohos:text="Right"
ohos:text_alignment="center"
ohos:text_size="20fp"/>
</PositionLayout>
版权说明 : 本文为转载文章, 版权归原作者所有 版权申明
原文链接 : https://blog.csdn.net/Forever_wj/article/details/118249977
内容来源于网络,如有侵权,请联系作者删除!