Support Library -- Percent

一、概念

Percent Support Library是Google百分比布局兼容函数库,进行屏幕适配。

二、属性

使用android.support.percent.PercentRelativeLayout和android.support.percent.PercentFrameLayout分别替代掉RelativeLayout和FrameLayout。
现有以下属性可以使用:

layout_widthPercent : 宽度的百分比 ,例如:app:layout_widthPercent="25%"
layout_heightPercent : 高度的百分比
layout_marginPercent : 边距的百分比
layout_marginLeftPercent
layout_marginRightPercent
layout_marginTopPercent
layout_marginBottomPercent
layout_marginStartPercent
layout_marginEndPercent

layout_aspectRatio : 用百分比来表示View的宽高比。

三、使用

使用Percent Support Library例子

首先需要在build.gradle文件中添加依赖:

dependencies {
    compile 'com.android.support:percent:23.2.0'
}

代码如下:


 
    
 

不使用Percent Support Library例子


 
    
 
        
 
        
 
    
 

你可能感兴趣的:(Support Library -- Percent)