线性布局-LinearLayout
- 线性布局不会换行,当组件一个挨着一个排列到头之后,剩下的组件将不会被显示出来。
- 线性布局中最重要的两个属性
android:orientation 设置布局管理器内组件的排列方式
水平排列:horizontal 垂直排列:vertical
android:gravity 设置布局管理器内组件的对齐方式
top|bottom|left|right|center_vertical|center_horizontal|center|…
- Android:gravity属性中的多个属性值之间可以用竖线隔开
<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>