告别适配噩梦:Android百分比布局扩展库完全指南
你还在为多屏幕尺寸适配编写数十个dimens文件吗?还在为复杂UI的比例计算抓狂吗?本文将彻底解决你的布局适配痛点——通过android-percent-support-extend库,仅需几行代码即可实现完美的百分比布局,支持边距、内边距、文本大小甚至屏幕尺寸百分比定义,让你的UI在手机、平板上都能保持一致的视觉体验。
读完本文你将获得:
- 掌握3种核心百分比布局容器的使用技巧
- 学会12种百分比属性的精准应用
- 解决ScrollView嵌套等高难题
- 实现跨设备的完美UI适配方案
- 获取5个企业级实战案例的完整代码
项目概述:超越官方的百分比布局解决方案
什么是android-percent-support-extend?
android-percent-support-extend是对Google官方百分比布局库的增强扩展,它保留了原库简洁的百分比语法,同时新增了padding、textSize、min/max尺寸等关键特性,解决了官方库在实际开发中的诸多限制。该库通过自定义布局容器和属性解析机制,允许开发者直接在XML中使用百分比定义视图的尺寸、边距、内边距甚至文本大小,极大简化了多屏幕适配工作。
与官方库核心差异对比
| 功能特性 | 官方Percent库 | 本扩展库 | 解决的痛点 |
|---|---|---|---|
| 基础宽高百分比 | ✅ | ✅ | 基础比例定义 |
| 边距百分比 | ✅ | ✅ | 相对位置控制 |
| 内边距百分比 | ❌ | ✅ | 容器内部间距适配 |
| 文本大小百分比 | ❌ | ✅ | 文字大小随容器/屏幕变化 |
| 最小/最大尺寸百分比 | ❌ | ✅ | 视图尺寸边界控制 |
| 屏幕尺寸基准百分比 | ❌ | ✅ | 基于屏幕宽高的比例定义 |
| ScrollView嵌套支持 | ❌ | ✅ | 解决滚动容器内高度计算问题 |
| 基准维度切换 | ❌ | ✅ | 可切换父容器/屏幕作为基准 |
核心功能解析:构建灵活的百分比布局系统
架构设计与工作原理
该库的核心架构基于装饰器模式扩展了Android原生布局容器,通过PercentLayoutHelper协调布局测量过程:
布局测量流程如下:
- 自定义布局容器(如PercentFrameLayout)重写
onMeasure方法 - 调用
PercentLayoutHelper.adjustChildren()解析百分比属性并转换为实际像素值 - 执行原生测量逻辑
- 若测量结果过小(如内容超出百分比限制),触发二次测量
- 布局完成后恢复原始参数,避免后续布局错乱
五大核心扩展功能详解
1. 内边距百分比(Padding Percent)
扩展库允许使用百分比定义视图的内边距,解决了不同屏幕尺寸下内边距适配问题:
<com.zhy.android.percent.support.PercentFrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_paddingLeftPercent="5.5%w"
app:layout_paddingRightPercent="5.5%w"
app:layout_paddingTopPercent="3%h"
app:layout_paddingBottomPercent="3%h">
<!-- 子视图将自动获得基于父容器宽度/高度的内边距 -->
</com.zhy.android.percent.support.PercentFrameLayout>
2. 文本大小百分比(TextSize Percent)
通过layout_textSizePercent属性,文本大小可随容器或屏幕尺寸动态调整:
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="动态文本大小"
app:layout_textSizePercent="4%h"/> <!-- 基于父容器高度的4% -->
3. 屏幕基准百分比(Screen-based Percent)
支持直接基于屏幕宽高定义尺寸,实现跨设备的绝对比例控制:
<ImageView
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_widthPercent="30%sw" <!-- 屏幕宽度的30% -->
app:layout_heightPercent="20%sh" <!-- 屏幕高度的20% -->
app:layout_marginTopPercent="15%sh"/> <!-- 屏幕高度的15%作为上边距 -->
4. 最小/最大尺寸百分比(Min/Max Dimension Percent)
控制视图的最小/最大尺寸,避免视图在极端情况下变形:
<Button
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_widthPercent="50%w"
app:layout_heightPercent="10%h"
app:layout_minWidthPercent="120%sw" <!-- 最小宽度为屏幕宽度的12% -->
app:layout_maxHeightPercent="8%h"/> <!-- 最大高度为父容器高度的8% -->
5. ScrollView嵌套支持
PercentLinearLayout特别优化了ScrollView嵌套场景,解决了高度计算不准确的问题:
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.zhy.android.percent.support.PercentLinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<!-- 子视图可使用百分比高度,LinearLayout会正确计算总高度 -->
</com.zhy.android.percent.support.PercentLinearLayout>
</ScrollView>
快速上手:从零开始的集成与使用
环境准备与安装
-
获取库文件
将库项目克隆到本地:
git clone https://gitcode.com/gh_mirrors/an/android-percent-support-extend.git -
添加到Android项目
在Android Studio中通过"File > New > Import Module"导入
percent-support-extends模块,然后在app模块的build.gradle中添加依赖:dependencies { implementation project(':percent-support-extends') } -
配置命名空间
在布局文件中添加自定义命名空间:
xmlns:app="http://schemas.android.com/apk/res-auto"
基础使用流程
使用百分比布局只需三步:
- 选择合适的百分比容器
- 设置子视图的百分比属性
- 指定基准维度(可选)
<!-- 1. 选择容器 -->
<com.zhy.android.percent.support.PercentRelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- 2. 设置百分比属性 -->
<ImageView
android:id="@+id/image"
android:layout_width="0dp" <!-- 必须设为0dp -->
android:layout_height="0dp" <!-- 必须设为0dp -->
android:src="@drawable/banner"
app:layout_widthPercent="80%w" <!-- 3. 基于父容器宽度的80% -->
app:layout_heightPercent="30%h" <!-- 基于父容器高度的30% -->
app:layout_marginTopPercent="5%h"
app:layout_marginLeftPercent="10%w"/>
</com.zhy.android.percent.support.PercentRelativeLayout>
支持的布局容器与属性
布局容器类型
库提供三种核心布局容器,覆盖大部分布局场景:
| 容器类 | 继承自 | 适用场景 | 特性 |
|---|---|---|---|
| PercentFrameLayout | FrameLayout | 层叠布局 | 支持FrameLayout的所有特性+百分比属性 |
| PercentRelativeLayout | RelativeLayout | 相对定位布局 | 支持RelativeLayout的所有特性+百分比属性 |
| PercentLinearLayout | LinearLayout | 线性排列布局 | 支持LinearLayout的所有特性+百分比属性,优化了ScrollView嵌套 |
完整属性参考
所有支持的百分比属性及其基准维度:
| 属性名 | 描述 | 默认基准 | 可指定基准 |
|---|---|---|---|
| layout_widthPercent | 宽度百分比 | 父容器宽度 | %w(父宽)/%sw(屏幕宽) |
| layout_heightPercent | 高度百分比 | 父容器高度 | %h(父高)/%sh(屏幕高) |
| layout_marginPercent | 四边边距百分比 | 父容器宽度 | %w/%h/%sw/%sh |
| layout_marginLeftPercent | 左边距百分比 | 父容器宽度 | %w/%h/%sw/%sh |
| layout_marginTopPercent | 上边距百分比 | 父容器高度 | %w/%h/%sw/%sh |
| layout_marginRightPercent | 右边距百分比 | 父容器宽度 | %w/%h/%sw/%sh |
| layout_marginBottomPercent | 下边距百分比 | 父容器高度 | %w/%h/%sw/%sh |
| layout_paddingPercent | 四边内边距百分比 | 父容器宽度 | %w/%h/%sw/%sh |
| layout_paddingLeftPercent | 左内边距百分比 | 父容器宽度 | %w/%h/%sw/%sh |
| layout_paddingTopPercent | 上内边距百分比 | 父容器宽度 | %w/%h/%sw/%sh |
| layout_paddingRightPercent | 右内边距百分比 | 父容器宽度 | %w/%h/%sw/%sh |
| layout_paddingBottomPercent | 下内边距百分比 | 父容器宽度 | %w/%h/%sw/%sh |
| layout_textSizePercent | 文本大小百分比 | 父容器高度 | %w/%h/%sw/%sh |
| layout_minWidthPercent | 最小宽度百分比 | 父容器宽度 | %w/%h/%sw/%sh |
| layout_minHeightPercent | 最小高度百分比 | 父容器高度 | %w/%h/%sw/%sh |
| layout_maxWidthPercent | 最大宽度百分比 | 父容器宽度 | %w/%h/%sw/%sh |
| layout_maxHeightPercent | 最大高度百分比 | 父容器高度 | %w/%h/%sw/%sh |
实战案例:企业级场景解决方案
案例1:登录界面完美适配
实现一个在任何屏幕尺寸下都保持视觉比例的登录界面:
<com.zhy.android.percent.support.PercentRelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white">
<!-- logo图片 - 基于屏幕宽度的40% -->
<ImageView
android:id="@+id/logo"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_centerHorizontal="true"
android:src="@drawable/logo"
app:layout_widthPercent="40%sw"
app:layout_heightPercent="40%sw" <!-- 保持宽高比 -->
app:layout_marginTopPercent="15%sh"/> <!-- 屏幕高度15%的上边距 -->
<!-- 用户名输入框 -->
<EditText
android:id="@+id/et_username"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_below="@id/logo"
android:layout_centerHorizontal="true"
android:hint="用户名"
app:layout_widthPercent="80%sw" <!-- 屏幕宽度80% -->
app:layout_heightPercent="8%sh" <!-- 屏幕高度8% -->
app:layout_marginTopPercent="8%sh"
app:layout_textSizePercent="3%h"/> <!-- 自身高度3%的文字大小 -->
<!-- 密码输入框 -->
<EditText
android:id="@+id/et_password"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_below="@id/et_username"
android:layout_centerHorizontal="true"
android:hint="密码"
android:inputType="textPassword"
app:layout_widthPercent="80%sw"
app:layout_heightPercent="8%sh"
app:layout_marginTopPercent="3%sh"
app:layout_textSizePercent="3%h"/>
<!-- 登录按钮 -->
<Button
android:id="@+id/btn_login"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_below="@id/et_password"
android:layout_centerHorizontal="true"
android:background="@color/primary"
android:text="登录"
android:textColor="@color/white"
app:layout_widthPercent="80%sw"
app:layout_heightPercent="8%sh"
app:layout_marginTopPercent="6%sh"
app:layout_textSizePercent="3.5%h"/>
<!-- 底部文字 -->
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:text="忘记密码? | 注册账号"
app:layout_marginBottomPercent="5%sh"
app:layout_textSizePercent="2.5%sh"/> <!-- 屏幕高度2.5%的文字大小 -->
</com.zhy.android.percent.support.PercentRelativeLayout>
案例2:新闻列表项布局
实现新闻APP中的列表项,在不同屏幕尺寸保持一致的视觉比例:
<com.zhy.android.percent.support.PercentRelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_heightPercent="25%h"> <!-- 列表项高度为父容器(屏幕)高度的25% -->
<!-- 新闻图片 -->
<ImageView
android:id="@+id/iv_news"
android:layout_width="0dp"
android:layout_height="0dp"
android:scaleType="centerCrop"
app:layout_widthPercent="35%w" <!-- 父容器宽度35% -->
app:layout_heightPercent="80%h"
app:layout_marginLeftPercent="3%w"
app:layout_marginTopPercent="10%h"/> <!-- 父容器高度10%的上边距 -->
<!-- 新闻标题 -->
<TextView
android:id="@+id/tv_title"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_toRightOf="@id/iv_news"
android:ellipsize="end"
android:maxLines="2"
android:textSize="16sp"
app:layout_widthPercent="55%w" <!-- 父容器宽度55% -->
app:layout_heightPercent="50%h"
app:layout_marginLeftPercent="4%w"
app:layout_marginTopPercent="10%h"
app:layout_textSizePercent="4%h"/> <!-- 自身高度4%的文字大小 -->
<!-- 新闻来源和时间 -->
<TextView
android:id="@+id/tv_source_time"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_below="@id/tv_title"
android:layout_toRightOf="@id/iv_news"
android:textSize="12sp"
app:layout_widthPercent="55%w"
app:layout_heightPercent="20%h"
app:layout_marginLeftPercent="4%w"
app:layout_marginTopPercent="5%h"
app:layout_textSizePercent="3.5%h"/>
</com.zhy.android.percent.support.PercentRelativeLayout>
案例3:ScrollView中的复杂表单
解决ScrollView中使用百分比布局的高度计算问题:
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<com.zhy.android.percent.support.PercentLinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" <!-- 关键:使用wrap_content -->
android:orientation="vertical"
app:layout_paddingLeftPercent="5%w"
app:layout_paddingRightPercent="5%w">
<!-- 表单标题 -->
<TextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:text="个人信息表单"
android:textStyle="bold"
app:layout_heightPercent="8%h" <!-- 基于父容器高度 -->
app:layout_textSizePercent="5%h"/>
<!-- 姓名输入区 -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:orientation="horizontal"
app:layout_heightPercent="10%h"
app:layout_marginTopPercent="5%h">
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:text="姓名:"
app:layout_widthPercent="25%w"
app:layout_textSizePercent="4%h"/>
<EditText
android:layout_width="0dp"
android:layout_height="match_parent"
android:hint="请输入姓名"
app:layout_widthPercent="75%w"
app:layout_textSizePercent="3.5%h"/>
</LinearLayout>
<!-- 更多表单项... -->
<!-- 提交按钮 -->
<Button
android:layout_width="0dp"
android:layout_height="0dp"
android:text="提交表单"
app:layout_heightPercent="12%h"
app:layout_marginTopPercent="8%h"
app:layout_widthPercent="100%w"
app:layout_textSizePercent="4%h"/>
</com.zhy.android.percent.support.PercentLinearLayout>
</ScrollView>
案例4:响应式网格布局
实现类似瀑布流的响应式网格,在不同屏幕宽度下自动调整列数:
<com.zhy.android.percent.support.PercentFrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- 第一行 -->
<com.zhy.android.percent.support.PercentLinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:orientation="horizontal"
app:layout_heightPercent="30%h">
<ImageView
android:layout_width="0dp"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:src="@drawable/img1"
app:layout_marginLeftPercent="2%w"
app:layout_marginRightPercent="1%w"
app:layout_widthPercent="31.33%w"/> <!-- (100-2-1*2)/3 = 31.33 -->
<ImageView
android:layout_width="0dp"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:src="@drawable/img2"
app:layout_marginLeftPercent="1%w"
app:layout_marginRightPercent="1%w"
app:layout_widthPercent="31.33%w"/>
<ImageView
android:layout_width="0dp"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:src="@drawable/img3"
app:layout_marginLeftPercent="1%w"
app:layout_marginRightPercent="2%w"
app:layout_widthPercent="31.33%w"/>
</com.zhy.android.percent.support.PercentLinearLayout>
<!-- 第二行 -->
<com.zhy.android.percent.support.PercentLinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_gravity="bottom"
android:orientation="horizontal"
app:layout_heightPercent="30%h">
<!-- 类似第一行的图片布局... -->
</com.zhy.android.percent.support.PercentLinearLayout>
</com.zhy.android.percent.support.PercentFrameLayout>
案例5:复杂仪表盘界面
结合多种百分比属性实现数据可视化仪表盘:
<com.zhy.android.percent.support.PercentRelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#f5f5f5">
<!-- 标题栏 -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:background="@color/primary"
android:gravity="center"
android:orientation="horizontal"
app:layout_heightPercent="10%h">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="数据仪表盘"
android:textColor="@color/white"
app:layout_textSizePercent="5%h"/>
</LinearLayout>
<!-- 核心数据卡片 -->
<LinearLayout
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_below="@id/title_bar"
android:layout_centerHorizontal="true"
android:background="@drawable/card_bg"
android:orientation="vertical"
app:layout_heightPercent="30%h"
app:layout_marginTopPercent="5%h"
app:layout_widthPercent="90%sw">
<TextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:gravity="center"
android:text="今日销售额"
app:layout_heightPercent="30%h"
app:layout_textSizePercent="4%h"/>
<TextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:gravity="center"
android:text="¥128,500"
android:textColor="@color/primary"
android:textStyle="bold"
app:layout_heightPercent="70%h"
app:layout_textSizePercent="8%h"/>
</LinearLayout>
<!-- 数据指标卡片网格 -->
<com.zhy.android.percent.support.PercentLinearLayout
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_below="@id/core_data"
android:layout_centerHorizontal="true"
android:orientation="horizontal"
app:layout_heightPercent="25%h"
app:layout_marginTopPercent="5%h"
app:layout_widthPercent="90%sw">
<!-- 指标卡片1 -->
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginRightPercent="2%w"
android:background="@drawable/card_bg"
android:orientation="vertical"
app:layout_widthPercent="48%w">
<TextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:gravity="center"
android:text="订单数"
app:layout_heightPercent="40%h"
app:layout_textSizePercent="3.5%h"/>
<TextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:gravity="center"
android:text="258"
android:textColor="@color/accent"
app:layout_heightPercent="60%h"
app:layout_textSizePercent="7%h"/>
</LinearLayout>
<!-- 指标卡片2 -->
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginLeftPercent="2%w"
android:background="@drawable/card_bg"
android:orientation="vertical"
app:layout_widthPercent="48%w">
<!-- 类似卡片1的内容... -->
</LinearLayout>
</com.zhy.android.percent.support.PercentLinearLayout>
<!-- 更多数据展示... -->
</com.zhy.android.percent.support.PercentRelativeLayout>
高级技巧与最佳实践
基准维度选择策略
选择合适的基准维度对布局效果至关重要,以下是推荐的选择策略:
常见问题解决方案
问题1:布局闪烁或测量不准确
原因:百分比布局需要两次测量过程,可能导致短暂闪烁。
解决方案:
// 在Activity中添加以下代码优化测量
@Override
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
if (hasFocus) {
// 触发重新布局
View rootView = findViewById(android.R.id.content);
rootView.requestLayout();
}
}
问题2:在RecyclerView/ListView中使用时性能低下
原因:每个列表项都使用百分比布局会增加测量开销。
解决方案:
- 为列表项布局设置固定尺寸缓存
- 避免在列表项中使用复杂的嵌套百分比布局
- 考虑使用ItemViewType复用不同类型的布局
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_layout, parent, false);
// 设置固定尺寸缓存
PercentLayoutHelper helper = new PercentLayoutHelper((ViewGroup) view);
helper.adjustChildren(View.MeasureSpec.makeMeasureSpec(parent.getWidth(), View.MeasureSpec.EXACTLY),
View.MeasureSpec.makeMeasureSpec(parent.getHeight()/3, View.MeasureSpec.EXACTLY));
return new ViewHolder(view);
}
问题3:与ConstraintLayout的混合使用
解决方案:将百分比布局作为ConstraintLayout的子布局使用,结合两者优势:
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- 使用ConstraintLayout定位 -->
<com.zhy.android.percent.support.PercentFrameLayout
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_heightPercent="80%h"
app:layout_widthPercent="80%w">
<!-- 内部使用百分比布局 -->
</com.zhy.android.percent.support.PercentFrameLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
性能优化建议
- 减少嵌套层级:百分比布局本身已经进行了额外计算,避免多层嵌套
- 避免过度使用屏幕基准:%sw和%sh需要获取屏幕尺寸,增加计算开销
- 复用布局:使用include标签复用相同结构的百分比布局
- 限制动态修改:频繁修改百分比属性会导致多次测量,尽量在初始化时设置
- 使用merge标签:减少根布局层级
总结与展望
android-percent-support-extend库通过扩展官方百分比布局,解决了实际开发中的诸多适配难题,提供了更加灵活和强大的百分比布局解决方案。本文详细介绍了该库的核心功能、使用方法和实战案例,涵盖了从基础集成到高级技巧的各个方面。
通过掌握本文介绍的知识,开发者可以:
- 大幅减少多屏幕适配的工作量
- 实现更加灵活和响应式的UI设计
- 提高布局代码的可读性和维护性
- 解决复杂界面的比例适配问题
未来,随着Jetpack Compose的普及,百分比布局的概念可能会以新的形式存在,但在传统View系统中,android-percent-support-extend仍然是解决多屏幕适配的高效方案。建议开发者在实际项目中根据需求灵活运用,并关注库的更新和社区贡献。
希望本文能够帮助你彻底解决Android布局适配的痛点,构建出更加专业和美观的用户界面!如果你有任何使用问题或建议,欢迎在项目仓库中提交issue或PR。
附录:完整属性速查表
| 属性名 | XML命名空间 | 数据类型 | 基准类型 | 描述 |
|---|---|---|---|---|
| layout_widthPercent | app | string | %w/%h/%sw/%sh | 宽度百分比 |
| layout_heightPercent | app | string | %w/%h/%sw/%sh | 高度百分比 |
| layout_marginPercent | app | string | %w/%h/%sw/%sh | 四边边距百分比 |
| layout_marginLeftPercent | app | string | %w/%h/%sw/%sh | 左边距百分比 |
| layout_marginTopPercent | app | string | %w/%h/%sw/%sh | 上边距百分比 |
| layout_marginRightPercent | app | string | %w/%h/%sw/%sh | 右边距百分比 |
| layout_marginBottomPercent | app | string | %w/%h/%sw/%sh | 下边距百分比 |
| layout_paddingPercent | app | string | %w/%h/%sw/%sh | 四边内边距百分比 |
| layout_paddingLeftPercent | app | string | %w/%h/%sw/%sh | 左内边距百分比 |
| layout_paddingTopPercent | app | string | %w/%h/%sw/%sh | 上内边距百分比 |
| layout_paddingRightPercent | app | string | %w/%h/%sw/%sh | 右内边距百分比 |
| layout_paddingBottomPercent | app | string | %w/%h/%sw/%sh | 下内边距百分比 |
| layout_textSizePercent | app | string | %w/%h/%sw/%sh | 文本大小百分比 |
| layout_minWidthPercent | app | string | %w/%h/%sw/%sh | 最小宽度百分比 |
| layout_minHeightPercent | app | string | %w/%h/%sw/%sh | 最小高度百分比 |
| layout_maxWidthPercent | app | string | %w/%h/%sw/%sh | 最大宽度百分比 |
| layout_maxHeightPercent | app | string | %w/%h/%sw/%sh | 最大高度百分比 |
创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考



