1. 程式人生 > >the Percentage Layout of Android (安卓的百分比佈局)

the Percentage Layout of Android (安卓的百分比佈局)

不用wrap_content.match_parent來指定 控制元件的大小,

1.在app/bulid.gradle檔案的dependencies中新增

compile 'com.android.support:percent:24.2.1(注意在新增檔案之後要同步一下)

2.修改佈局檔案xml檔案中的佈局

比如<Button android:id="@+id/button1"

android:text="button 1"

android:layout_gravit="left|toop"

app:layout_widthPercent="50%"

app:layout_heightPercent="20%"

/>