鸿蒙系统学习八-DirectionalLayout和DependentLayout 常用API方法

9 篇文章 0 订阅
9 篇文章 0 订阅

鸿蒙 UI控件分为Component 和 ComponentContainer,类似Android里面的View和ViewGroup

  • Component:是界面中所有组件的基类,如 Text、Image 等
  • ComponentContainer:标准布局功能的容器的基类。如 DirectionalLayout、DependentLayout 等。DirectionalLayout类似Android的LinearLayout,DependentLayout类似Android的RelativeLayout

另外鸿蒙大小单位有三种px、fp、vp
px:像素
vp:以屏幕相对像素为单位,也就是安卓中的dp
fp:相当于sp

控件API

在这里插入图片描述

命名:$+id:
match_content等价于Android wrop_parent
match_parent与Android一致
text 与Android一致
text_size 与Android一致
text_color 与Android一致
padding 与Android一致
top_margin 等价于Android margin_top
background_element 等价于Android的background
其他API后续再补充。

页面布局

DirectionalLayout

DirectionalLayout 的排列方向(orientation)分为水平(horizontal)或者垂直(vertical) 方向。使用 orientation 设置布局内组件的排列方式,默认为垂直排列,与LinearLayout一致,其他api有细微差别。
1.layout_alignment:
在这里插入图片描述

DependentLayout

相对布局,与RelativeLayout类似,具体API如下:
在这里插入图片描述
控制控件位置API
在这里插入图片描述
在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值