屏幕适配1(Android 增强版百分比布局库 为了适配而扩展)

时间:2023-03-08 18:43:14

转载请标明出处: 
http://blog.****.net/lmj623565791/article/details/46767825; 
本文出自:【张鸿洋的博客】

这篇博文写得太好了,让我很激动,分享分享!

详细请前往出处 http://blog.****.net/lmj623565791/article/details/46767825 进行学习

我这里给出我导入时的步骤和使用方法吧!

导入步骤:

1、https://github.com/hongyangAndroid/android-percent-support-extend 下载,解压

屏幕适配1(Android 增强版百分比布局库 为了适配而扩展)

2、在 android stdio 中导入Model

屏幕适配1(Android 增强版百分比布局库 为了适配而扩展)

3、编译,如果出错,就根据出错的提示,把出错的信息屏蔽掉

4、使用

<?xml version="1.0" encoding="utf-8"?>

<com.zhy.android.percent.support.PercentLinearLayout

    xmlns:android="http://schemas.android.com/apk/res/android"

    xmlns:app="http://schemas.android.com/apk/res-auto"

    android:layout_width="match_parent"

    android:layout_height="match_parent"

      >

    <TextView

        android:width="0dp"

        android:height="0dp"

        app:layout_heightPercent="20%"

        app:layout_widthPercent="30%"

        android:text="很好"

        android:background="@android:color/holo_blue_light"

        />

    <TextView

        android:width="0dp"

        android:height="0dp"

        app:layout_heightPercent="80%"

        app:layout_widthPercent="70%"

        android:text="你好啊"

        android:background="@android:color/holo_red_light"

        />

</com.zhy.android.percent.support.PercentLinearLayout>