【Android】Percent Support Library实践
来源:互联网 发布:免费的crm软件 编辑:程序博客网 时间:2024/06/06 00:32
Percent Support Library 用于使用百分比控制子View在布局里面占用的大小,相比于layout_weight这个属性具有更高的灵活性,并且margin属性也支持使用百分比控制,这是layout_weight不具备的,官方只提供了PercentFrameLayout和PercentRelativeLayout。目前支持的属性有:
layout_widthPercentlayout_heightPercentlayout_marginPercentlayout_marginLeftPercentlayout_marginTopPercentlayout_marginRightPercentlayout_marginBottomPercentlayout_marginStartPercentlayout_marginEndPercentlayout_aspectRatio 宽高比例
bulid.gradle引用
compile 'com.android.support:percent:26.1.0'
布局使用
<?xml version="1.0" encoding="utf-8"?><android.support.percent.PercentRelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/content" android:layout_width="match_parent" android:layout_height="match_parent"> <View android:id="@+id/view1" android:layout_alignParentLeft="true" android:layout_alignParentStart="true" android:layout_alignParentTop="true" android:background="#333366" app:layout_heightPercent="10%" app:layout_widthPercent="25%"/> <View android:id="@+id/view2" android:layout_toRightOf="@id/view1" app:layout_widthPercent="25%" app:layout_heightPercent="10%" android:background="#999933"/> <View android:id="@+id/view3" android:layout_toRightOf="@id/view2" app:layout_widthPercent="25%" app:layout_heightPercent="10%" android:background="#996600"/> <View android:id="@+id/view4" android:layout_toRightOf="@id/view3" app:layout_widthPercent="25%" app:layout_heightPercent="10%" android:background="#333333"/> <View android:id="@+id/view5" app:layout_aspectRatio="578%" app:layout_widthPercent="100%" app:layout_marginTopPercent="10%" android:background="#669999" /> <View android:id="@+id/view6" android:layout_alignParentLeft="true" android:layout_alignParentStart="true" android:layout_alignParentBottom="true" app:layout_widthPercent="50%" app:layout_heightPercent="10%" android:background="#669999" /> <View android:id="@+id/view7" android:layout_alignParentBottom="true" android:layout_toRightOf="@id/view6" app:layout_widthPercent="25%" app:layout_heightPercent="10%" android:background="#999933"/></android.support.percent.PercentRelativeLayout>
效果图:
在Android中这种百分比布局已经被ConstraintLayout所替代。
阅读全文
0 0
- 【Android】Percent Support Library实践
- android support Library—-Percent Support Library
- Android 百分比布局(Percent Support Library)
- Android进阶系列之Percent Support Library使用详解
- Percent Support Library使用详解
- Android percent-support-lib
- android-percent-support-extend
- Android Design Support Library实践之Snackbar
- Android Design Support Library初探,NavigationView实践
- Android Design Support Library初探,NavigationView实践
- Android Design Support Library,NavigationView实践
- android-percent-support-lib-sample
- android-percent-support-lib-sample
- support-percent
- Android 百分比支持库 android-percent-support
- Android--百分比布局库(percent-support-lib)
- android-support-percent的学习使用笔记
- Android 百分比布局库(percent-support-lib)
- mysql order by limit slow 慢查询
- Bitmap 的加载
- 获取数据库字符串最大值
- HTML5伪类选择器
- Pixhawk入门指南-目录
- 【Android】Percent Support Library实践
- 大数据名词分析
- 公众号编辑器开发,实现编辑器前端页面
- C语言实现顺序表
- 在tomcat里为多个应用配置不同的访问端口
- (14)文件上传
- Objective-C学习总结#2——预处理
- 二维数组根据某个相同的值归类
- CSS3 盒布局