参考:http://blog.csdn.net/lmj623565791/article/details/46767825
传送门:https://github.com/hongyangAndroid/android-percent-support-extend
参照父布局使用20%w,参照屏幕29&sw,对于srollview使用srollview嵌套percentLinelayout,内部使用sw
dependencies { //... compile 'com.zhy:percent-support-extends:1.0.1'}
<com.zhy.android.percent.support.PercentRelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">
<android.support.v4.view.ViewPager
app:layout_heightPercent="100%"
app:layout_widthPercent="100%"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_centerInParent="true"
android:id="@+id/viewpage"></android.support.v4.view.ViewPager>
<com.zhy.android.percent.support.PercentLinearLayout
android:background="#FFFFFF"
app:layout_heightPercent="9.5%h"
app:layout_widthPercent="100%w"
android:layout_width="0dp"
android:layout_height="0dp"
android:orientation="horizontal"
android:layout_alignParentBottom="true">
<com.zhy.android.percent.support.PercentRelativeLayout
android:id="@+id/rel_find"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1">
<ImageView
android:layout_centerHorizontal="true"
app:layout_heightPercent="42%h"
app:layout_widthPercent="42%h"
android:background="@drawable/faxian"
android:id="@+id/img_find"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_alignParentTop="true"
app:layout_marginTopPercent="15%h"/>
<TextView
android:layout_centerHorizontal="true"
android:textSize="18.0sp"
android:text="发现"
android:id="@+id/tex_find"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
app:layout_marginBottomPercent="15%h"/>
</com.zhy.android.percent.support.PercentRelativeLayout>
<com.zhy.android.percent.support.PercentRelativeLayout
android:id="@+id/rel_zhishui"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1">
<ImageView
android:layout_centerHorizontal="true"
app:layout_heightPercent="42%h"
app:layout_widthPercent="42%h"
android:background="@drawable/zhishui"
android:id="@+id/img_zhishui"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_alignParentTop="true"
app:layout_marginTopPercent="15%h"
/>
<TextView
android:layout_centerHorizontal="true"
android:textSize="18.0sp"
android:text="智睡"
android:id="@+id/tex_zhishui"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
app:layout_marginBottomPercent="15%h"/>
</com.zhy.android.percent.support.PercentRelativeLayout>
<com.zhy.android.percent.support.PercentRelativeLayout
android:id="@+id/rel_me"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1">
<ImageView
android:layout_centerHorizontal="true"
app:layout_heightPercent="42%h"
app:layout_widthPercent="42%h"
android:background="@drawable/wode"
android:id="@+id/img_me"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_alignParentTop="true"
app:layout_marginTopPercent="15%h"
/>
<TextView
android:layout_centerHorizontal="true"
android:text="我的"
android:textSize="18.0sp"
android:id="@+id/tex_me"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
app:layout_marginBottomPercent="15%h"/>
</com.zhy.android.percent.support.PercentRelativeLayout>
</com.zhy.android.percent.support.PercentLinearLayout>
</com.zhy.android.percent.support.PercentRelativeLayout>