鸿蒙pageslider,2021-01-22鸿蒙开发(二)

常用布局

1.线性布局DirectionalLayout

·DirectionalLayout是将布局横向或者纵向排列下来的

分为horizontal和vertical

vertical:

14e024829a36

image.png

xmlns:ohos="http://schemas.huawei.com/res/ohos"

ohos:height="match_parent"

ohos:width="match_parent"

ohos:orientation="vertical">

ohos:height="30vp"

ohos:width="60vp"

ohos:background_element="$graphic:background_ability_main"

ohos:text="Button1"/>

ohos:height="30vp"

ohos:top_margin="20fp"

ohos:width="60vp"

ohos:background_element="$graphic:background_ability_main"

ohos:text="Button2"/>

ohos:height="30vp"

ohos:width="60vp"

ohos:top_margin="20fp"

ohos:background_element="$graphic:background_ability_main"

ohos:text="Button3"/>

horizontal:

14e024829a36

image.png

weight的使用

·weight是按照组件的权重来分配组件按照父组件的可分配宽度之和

水平方向weight=0;

如果等于1的话三个按钮就是三等分如图效果

14e024829a36

image.png

ohos:weight="1"

2.相对布局DependentLayout

每个组件可以指定一个相对位置,可以使兄弟组件位置,或者父组件位置

14e024829a36

image.png

xmlns:ohos="http://schemas.huawei.com/res/ohos"

ohos:height="match_parent"

ohos:width="match_parent"

ohos:orientation="horizontal">

ohos:id="$+id:btn1"

ohos:height="30vp"

ohos:width="60vp"

ohos:background_element="$graphic:background_ability_main"

ohos:text="Button1"/>

ohos:id="$+id:btn2"

ohos:height="30vp"

ohos:width="60vp"

ohos:background_element="$graphic:background_ability_main"

ohos:right_of="$id:btn1"

ohos:left_margin="20fp"

ohos:text="Button2"/>

ohos:id="$+id:btn3"

ohos:height="30vp"

ohos:width="60vp"

ohos:background_element="$graphic:background_ability_main"

ohos:left_margin="20fp"

ohos:right_of="$id:btn2"

ohos:text="Button3"/>

交互类组件

如文本框,按钮,复选框,选择器,等

TextField、Button、Checkbox、RadioButton/RadioContainer、Switch、ToggleButton、Slider、Rating、ScrollView、TabList、ListContainer、PageSlider、PageFlipper、PageSliderIndicator、Picker、TimePicker、DatePicker、SurfaceProvider、ComponentProvider

显示类

如文本框,图片,时间控件,等

Text、Image、Clock、TickTimer、ProgressBar

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值