android PercentRelativeLayout 支持百分比来设置控件的宽高
Android 设置 支持 控件 百分比
2023-09-11 14:20:59 时间
Android 最终官方支持按百分比来设置控件的宽高了。
我们先来看看效果:
我们先来看看效果:
看一下布局:
PercentRelativeLayout
<android.support.percent.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"> <View android:id="@+id/top_left" android:layout_width="0dp" android:layout_height="0dp" android:layout_alignParentTop="true" android:background="#ff44aacc" app:layout_heightPercent="20%" app:layout_widthPercent="70%" /> <View android:id="@+id/top_right" android:layout_width="0dp" android:layout_height="0dp" android:layout_alignParentTop="true" android:layout_toRightOf="@+id/top_left" android:background="#ffe40000" app:layout_heightPercent="20%" app:layout_widthPercent="30%" /> <View android:id="@+id/bottom" android:layout_width="match_parent" android:layout_height="0dp" android:layout_below="@+id/top_left" android:background="#ff00ff22" app:layout_heightPercent="80%" /> </android.support.percent.PercentRelativeLayout>
PercentFrameLayout
<android.support.percent.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"> <!-- ... XML CODE --> </android.support.percent.PercentFrameLayout>
Stylable :
- heightPercent
- widthPercent
- marginBottomPercent
- marginEndPercent
- marginLeftPercent
- marginPercent
- marginRightPercent
- marginStartPercent
- marginTopPercent
支持:
- Android SDK v22
- Android Build Tools v22.0.1
- Android Percent Support Repository v22.2.0
- Android Support v4 Repository v22.2.0
according to the the manifest minsdk is v7 (android 2.1)
相关文章
- Android TextView设置个别字体样式
- Android中设置Button为透明
- Android中如何设置导航,从起点到终点
- android图片特效处理之怀旧效果
- Android: 分页浏览的利器 android View Pager
- Android Material风格的应用(四)--FloatActionButton
- 关于Android中设置闹钟的相对完善的解决方案
- 实现Android Studio JNI开发C/C++使用__android_log_print输出Log
- Android Studio ndk-Jni开发详细
- android 围绕中心旋转动画
- Android 字体设置
- android自定义viewgroup实现等分格子布局
- android开发:Android 中自定义属性(attr.xml,TypedArray)的使用
- Android 识别身份证号码(图片识别)
- android构建过程
- Android内存泄漏的八种可能
- android 开发-设置控件/view的水平方向翻转
- android开发设置dialog的高宽
- android-UI组件(四):AdapterView及其子类
- 最最实用的android studio设置教程
- Android深入四大组件(六)Service的启动过程
- Android支付宝SDK开发笔记
- Unity Android 之 获取蓝牙Bluetooth 的状态,设置的蓝牙Bluetooth 的开关状态,并监听蓝牙Bluetooth 的状态变化方法整理
- 【Android】使用Binder实现进程间传递对象案例
- Android Studio 3.X NDK 开发基础