HarmonyOS UI开发 match_parent与match_content
match_parent:
表示组件大小将扩展为父组件允许的最大值,它将占据父组件方向上的剩余大小
match_content:
表示组件大小与它的内容占据的大小范围相适应。
两者详细说明:
下面看下定向布局代码
<?xml version="1.0" encoding="utf-8"?>
<DirectionalLayoutxmlns:ohos="http://schemas.huawei.com/res/ohos"ohos:height="match_parent"ohos:width="match_parent"ohos:orientation="vertical"><Buttonohos:id="$+id:button1"ohos:height="match_content"ohos:width="match_parent"ohos:top_margin="10vp"ohos:background_element="#00d8a0"ohos:text_size="20fp"ohos:text="Java"/></DirectionalLayout>
match_parent
布局里面button 的宽度使用了match_parent 他的父类就是DirectionalLayout,而DirectionalLayout的的宽度也是设置了match_parent,它的最外层没有父类所以应该是整个屏幕的, 回头看看button 宽度应该占据了整个屏幕,
match_content 的大小是自己的宽度适应,就是button本身,
为了更好地理解在看一个例子
<?xml version="1.0" encoding="utf-8"?>
<DirectionalLayoutxmlns:ohos="http://schemas.huawei.com/res/ohos"ohos:height="200vp"ohos:width="200vp"ohos:background_element="#444fff"ohos:orientation="vertical"><Buttonohos:id="$+id:button1"ohos:height="match_content"ohos:width="match_parent"ohos:top_margin="10vp"ohos:background_element="#00d8a0"ohos:text_size="20fp"ohos:text="Java"/></DirectionalLayout>
效果图
HarmonyOS UI开发 match_parent与match_content相关推荐
- HarmonyOS UI开发 AdaptiveBoxLayout(自适应盒子布局) 的使用
AdaptiveBoxLayout 是什么 AdaptiveBoxLayout 是自适应盒子布局,该布局提供了在不同屏幕尺寸设备上的自适应布局能力,主要用于相同级别的多个组件需要在不同屏幕尺寸设备上自 ...
- HarmonyOS UI开发 TableLayout(表格布局) 的使用
TableLayout 是什么 TableLayout 是表格布局,就是使用表格的方式划分子组件, 个人感觉应该也不是常用的布局,常用的还是选择DirectionalLayout和Dependent ...
- HarmonyOS UI开发 PositionLayout(位置布局) 的使用
PositionLayout 是什么 PositionLayout 是位置布局,在PositionLayout中,子组件通过指定准确的x/y坐标值在屏幕上显示.(0, 0)为左上角:当向下或向右移动时 ...
- HarmonyOS UI开发 StackLayout(堆栈布局) 的使用
StackLayout是什么 StackLayout 是堆栈布局,直接在屏幕上开辟出一块空白的区域,添加到这个布局中的视图都是以层叠的方式显示,而它会把这些视图默认放到这块区域的左上角,第一个添加到布 ...
- HarmonyOS UI开发 DependentLayout(依赖布局) 的使用
DependentLayout是什么 DependentLayout是依赖布局,每个组件可以指定相对于其他同级元素的位置,或者指定相对于父组件的位置.(类似Android的相对布局) Dependen ...
- HarmonyOS UI开发 DirectionalLayout(定向布局) 的使用
DirectionalLayout 是什么 DirectionalLayout 是定向布局,控件水平或垂直排列(类似Android 的线性布局不过还是有区别的) DirectionalLayout的自 ...
- HarmonyOS UI 开发 vp ,fp , px 以及写具体数字的 理解
HarmonyOS 开发UI 距离和字体使用什么单位 距离使用 vp (virtual pixel) 字体大小使用 fp (font pixel) 详细了解 vp ,fp , px 虚拟像素单位:vp ...
- HarmonyOS APP开发入门3——组件(四 CommonDialog普通弹框组件 )
HarmonyOS APP开发入门3--组件(四 CommonDialog普通弹框组件 ) 文章目录 HarmonyOS APP开发入门3--组件(四 CommonDialog普通弹框组件 ) Com ...
- 3.5【HarmonyOS鸿蒙开发】组件RadioButton和RadioContainer
3.5[HarmonyOS鸿蒙开发]组件RadioButton和RadioContainer 作者:韩茹 公司:程序咖(北京)科技有限公司 鸿蒙巴士专栏作家 一.RadioButton RadioBu ...
最新文章
- java中next的用法_关于java iterator的next()方法的用法
- java selenium验证元素是否存在
- P3805 【模版】manacher算法(manacher)
- SQL 创建存储过程,让主键自增
- 将SQL-SERVER逆向工程导入Power-Design中并给表的字段添加注释
- QT信号与槽-启动系统程序以及相关控件介绍
- python汉语读音_【学习】python 汉语转拼音
- download plugin update site for offline installation
- 对volatile不具有原子性的理解
- java actionsupport_【JAVA学习】struts2 中 Actionsupport 的作用
- rfid sim卡 android,手机专用SIM卡的非接触移动支付技术标准之争:NFC vs RFID
- Python全栈工程师(22:Socket编程11-Select解析Socket通信)
- 百度_360_谷歌等各大搜索引擎网站收录提交入口
- Java20:NullPointerException
- 实习之路0--设计模式之策略模式的理解(鸭子类例子)
- 如何删除2345SafeCenterSvc
- word 要求五十行 50行
- kappa系数在评测中的应用
- JFinal 极速开发框架--5.ActiveRecord
- 我们问了人工智能ChatGPT十个运维问题,结果发现...
热门文章
- 【ReactiveX】基于Golang pmlpml/RxGo程序包的二次开发
- Chrome不支持showModalDialog的解决方案
- photoshop小结
- Python学习(四)cPickle的用法
- OneFlow系统设计
- 服务器技术综述(一)
- 长篇自动驾驶技术综述论文(下)
- 2021年大数据Spark(五十一):Structured Streaming 物联网设备数据分析
- AttributeError: ‘tuple‘ object has no attribute ‘group‘
- ecplise 设置代码自动提示功能的设置