百分比适配举例

参考: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>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值