Android ApiDemos示例解析(146):Views->Layouts->LinearLayout->6. Uniform Size
本例使用给LinearLayout 宽度和高度设为wrap_content 和将子View大小设为match_parent ,从而实现所有子View具有同样的大小:
<LinearLayout xmlns:android=”http://schemas.android.com/apk/res/android”
android:orientation=”vertical”
android:background=”@drawable/blue”
android:padding=”20dip”
android:layout_width=”wrap_content”
android:layout_height=”wrap_content“>
<TextView
android:background=”@drawable/box”
android:layout_width=”match_parent”
android:layout_height=”wrap_content”
android:text=”@string/linear_layout_6_one”/>
<TextView
android:background=”@drawable/box”
android:layout_width=”match_parent”
android:layout_height=”wrap_content”
android:text=”@string/linear_layout_6_two”/>
<TextView
android:background=”@drawable/box”
android:layout_width=”match_parent”
android:layout_height=”wrap_content”
android:text=”@string/linear_layout_6_three”/>
<TextView
android:background=”@drawable/box”
android:layout_width=”match_parent”
android:layout_height=”wrap_content”
android:text=”@string/linear_layout_6_four”/>
</LinearLayout>