<?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"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<!--四个按钮平分屏幕-->
<!--左上角-->
<Button
android:id="@+id/button_1"
android:text="Button 1"
android:layout_gravity="left|top"
app:layout_widthPercent="50%"
app:layout_heightPercent="50%"
/>
<!--右上角-->
<Button
android:id="@+id/button_2"
android:text="Button 2"
android:layout_gravity="right|top"
app:layout_widthPercent="50%"
app:layout_heightPercent="50%"
/>
<!--左下角-->
<Button
android:id="@+id/button_3"
android:text="Button 3"
android:layout_gravity="left|bottom"
app:layout_widthPercent="50%"
app:layout_heightPercent="50%"
/>
<!--右下角-->
<Button
android:id="@+id/button_4"
android:text="Button 4"
android:layout_gravity="right|bottom"
app:layout_widthPercent="50%"
app:layout_heightPercent="50%"
/>
</android.support.percent.PercentFrameLayout>
效果:
![](https://img.haomeiwen.com/i14601975/64e70e961c489fcf.gif)
百分比布局.gif
文件结构:
![](https://img.haomeiwen.com/i14601975/160c29ca7538a5a3.png)
xml文件
网友评论