線性布局-LinearLayout
- 線性布局不會換行,當組件一個挨著一個排列到頭之後,剩下的組件將不會被顯示出來。
- 線性布局中最重要的兩個屬性
android:orientation 設定布局管理器內組件的相片順序
水平排列:horizontal 垂直排列:vertical
android:gravity 設定布局管理器內組件的對齊
top|bottom|left|right|center_vertical|center_horizontal|center|…
- Android:gravity屬性中的多個屬性值之間可以用豎線隔開
View Code <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center|left">
<Button
android:layout_width="80dp"
android:layout_height="wrap_content"/>
<Button
android:layout_width="80dp"
android:layout_height="wrap_content"/>
<Button
android:layout_width="80dp"
android:layout_height="wrap_content"/>
<Button
android:layout_width="80dp"
android:layout_height="wrap_content"/>
<Button
android:layout_width="80dp"
android:layout_height="wrap_content"/>
<Button
android:layout_width="80dp"
android:layout_height="wrap_content"/>
</LinearLayout>