菜鸡学习之路之-----Android适配策略

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_30519365/article/details/52719277

比较现实也比较,开发用处大大

hyman 的autolayout

学习可以参考此大牛的csdn 博客 http://blog.csdn.net/lmj623565791/article/details/49990941

(强烈推荐,注意:一家之言大家可以当没说)

另外一种用局限性

而Android 5.0 Google官方推出了百分比布局支持库,意在解决大部分屏幕适配的问题。下面我就向大家详细介绍一下:
1、Google百分比布局支持库
(1)支持的布局


(2)支持的属性


(3)使用方法
1、加载android-support-percent-lib
dependencies {
    compile 'com.android.support:percent:22.2.0'
}

扫描二维码关注公众号,回复: 3456721 查看本文章
小李子:

<?xml version="1.0" encoding="utf-8"?>
<android.support.percent.PercentRelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <View android:layout_width="0dp"
        android:layout_height="0dp"
        android:background="#FF0000"
        app:layout_heightPercent="10%"
        app:layout_widthPercent="30%"
        android:id="@+id/v1"
        >
    </View>
    <View android:layout_width="0dp"
        android:layout_height="0dp"
        android:background="#00FF00"
        app:layout_heightPercent="20%"
        app:layout_widthPercent="60%"
        android:layout_below="@id/v1"
        >
    </View>

</android.support.percent.PercentRelativeLayout>


猜你喜欢

转载自blog.csdn.net/qq_30519365/article/details/52719277