基本屬性要求
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
</LinearLayout>
排列方向
- android:orientation
- 決定LinearLayout內部元件會以水平或是垂直排列。
- 如果沒有設定此屬性,LinearLayout預設會使用水平排列。
- vertical 垂直排列。
- horizontal 水平排列。
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button 1" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button 2" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button 1" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button 2" />
</LinearLayout>