Google開始支持百分比的方式布局了已經(jīng)大半年了吧(7個(gè)月骇钦??)
https://github.com/JulienGenoud/android-percent-support-lib-sample 這個(gè)項(xiàng)目闡述了百分比布局方式竞漾,方法眯搭。
support-lib
這個(gè)庫(kù)為我們提供了什么呢?
<li>兩種布局:
<pre>PercentRelativeLayout,PercentFrameLayout业岁,他們繼承自FrameLayout和RelativeLayout兩個(gè)容器類坦仍;</pre>
<li>支持的屬性有:
<pre>
占寬比,占高比
layout_widthPercent
layout_heightPercent
左上右下叨襟,開始繁扎,結(jié)束,外邊距比例
layout_marginLeftPercent
layout_marginTopPercent
layout_marginRightPercent
layout_marginBottomPercent
layout_marginStartPercent
layout_marginEndPercent
</pre>
也就是說糊闽,只要在開發(fā)過程中使用PercentRelativeLayout梳玫、PercentFrameLayout替換FrameLayout、RelativeLayout即可右犹。
How to use : https://github.com/JulienGenoud/android-percent-support-lib-sample
使用條件:
Pre-requisites
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)