標籤:android style class blog code java
android:orientation指定LinearLayout布局方向,值:vertical (垂直方向) 、horizontal(水平方向)
執行個體一:
<?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" ><Button android:layout_width="match_parent" android:layout_height="wrap_content" android:text="按鈕1" /><Button android:layout_width="match_parent" android:layout_height="wrap_content" android:text="按鈕2" /><Button android:layout_width="match_parent" android:layout_height="wrap_content" android:text="按鈕3" /><Button android:layout_width="match_parent" android:layout_height="wrap_content" android:text="按鈕4" /></LinearLayout>
執行個體二:
<?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="horizontal" ><Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="按鈕1" /><Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="按鈕2" /><Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="按鈕3" /><Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="按鈕4" /></LinearLayout>