手机网站被做跳转,厦门网站建设公司推荐,网站建设与管理就业去向,猴王水果竞猜网站建设不常用
在PositionLayout中#xff0c;子组件通过指定准确的x/y坐标值在屏幕上显示。(0, 0)为左上角#xff1b;当向下或向右移动时#xff0c;坐标值变大#xff1b;允许组件之间互相重叠
布局方式
PositionLayout以坐标的形式控制组件的显示位置#xff0c;允许组件相…不常用
在PositionLayout中子组件通过指定准确的x/y坐标值在屏幕上显示。(0, 0)为左上角当向下或向右移动时坐标值变大允许组件之间互相重叠
布局方式
PositionLayout以坐标的形式控制组件的显示位置允许组件相互重叠。
在layout目录下的XML文件中创建PositionLayout并添加多个组件并通过position_x和position_y属性设置子组件的坐标 ?xml version1.0 encodingutf-8?
PositionLayoutxmlns:ohoshttp://schemas.huawei.com/res/ohosohos:heightmatch_parentohos:widthmatch_parentTextohos:id$id:text_1ohos:heightmatch_contentohos:widthmatch_contentohos:background_element#FF485DECohos:layout_alignmenthorizontal_centerohos:text科技ohos:text_size40vp//PositionLayout
Text text (Text) findComponentById(ResourceTable.Id_text_1);设置显示位置
text.setContentPosition(200,300);
package com.example.myapplication.slice;import com.example.myapplication.ResourceTable;
import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.agp.components.Text;public class MainAbilitySlice extends AbilitySlice {Overridepublic void onStart(Intent intent) {super.onStart(intent);super.setUIContent(ResourceTable.Layout_ability_main);Text text (Text) findComponentById(ResourceTable.Id_text_1);text.setContentPosition(200,300);}Overridepublic void onActive() {super.onActive();}Overridepublic void onForeground(Intent intent) {super.onForeground(intent);}
}