添加依赖:
implementation 'com.android.support:percent:27.1.1'
接下来就看布局了:
跟布局:
控件:
红框框中的布局位置是必须有的
注意在设置宽高的时候是app
并且在后面一定要加Percent
设置占位百分比
全部布局代码:
<?xml version="1.0" encoding="utf-8"?>
<android.support.percent.PercentFrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_heig