赞
踩
- dependencies {
- ...
- implementation 'com.android.support:percent:27.0.2'
- }
- <?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"
- xmlns:tools="http://schemas.android.com/tools"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- tools:context=".MainActivity">
-
- <TextView
- android:layout_width="0dp"
- android:layout_height="0dp"
- android:id="@+id/one"
- android:background="#f0f000"
- app:layout_heightPercent="30%"
- app:layout_widthPercent="70%"
- android:text="Hello World!"
- />
- <TextView
- android:layout_width="0dp"
- android:layout_toRightOf="@id/one"
- android:layout_height="0dp"
- app:layout_heightPercent="30%"
- app:layout_widthPercent="30%"
- android:background="#ff0000"
- android:text="Hello World!"
- />
- <TextView
- android:layout_width="0dp"
- android:layout_below="@id/one"
- android:layout_height="0dp"
- app:layout_heightPercent="70%"
- app:layout_widthPercent="100%"
- android:background="#ff00ff"
- android:text="Hello World!"
- />
-
- </android.support.percent.PercentRelativeLayout>
- <?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"
- xmlns:tools="http://schemas.android.com/tools"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- tools:context=".MainActivity">
- <TextView
- android:layout_width="100dp"
- android:layout_height="0dp"
- app:layout_aspectRatio="50%"
- android:background="#ff00ff"
- android:text="Hello World!"
- />
- <TextView
- android:layout_width="100dp"
- android:layout_height="0dp"
- android:layout_alignParentRight="true"
- app:layout_aspectRatio="200%"
- android:background="#0f00ff"
- android:text="Hello World!"
- />
- </android.support.percent.PercentRelativeLayout>
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。