android percent布局导入库,Android5.X之百分比布局库(percent-support-lib) 解析与扩展

博客介绍了Android - percent - support库,该库有PercentRelativeLayout和PercentFrameLayout两种布局,继承自FrameLayout和RelativeLayout,支持宽高、margin等属性,还可自定义PercentLinearLayout,同时说明了在build.gradle添加依赖的使用方法。

1 概述

Android-percent-support这个库两种布局供大家使用: PercentRelativeLayout、PercentFrameLayout,通过名字就可以看出,这是继承自FrameLayout和RelativeLayout两个容器类;

支持的属性有(可以看到支持宽高,以及margin):

layout_widthPercent、layout_heightPercent、

layout_marginPercent、layout_marginLeftPercent、

layout_marginTopPercent、layout_marginRightPercent、

layout_marginBottomPercent、layout_marginStartPercent、layout_marginEndPercent。

接着,自定义一个PercentLinearLayout。

2 使用

首先记得在build.gradle添加

compile 'com.android.support:percent:22.2.0'

2.1 PercentRelativeLayout

0818b9ca8b590ca3270a3433284dd417.png

2.2 PercentFrameLayout

0818b9ca8b590ca3270a3433284dd417.png

2.3 复杂PercentRelativeLayout

0818b9ca8b590ca3270a3433284dd417.png

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值