这是我的布局 XML:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TableLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:stretchColumns="true">
<TableRow
android:background="#FF0000">
<ViewFlipper
android:id="@+id/viewer_something"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:id="@+id/view1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#CCCCCC">
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="button one" />
</LinearLayout>
<LinearLayout
android:id="@+id/view2"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#FFFFFF">
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="button two" />
</LinearLayout>
</ViewFlipper>
</TableRow>
<TableRow
android:background="#FF0000">
<Button
android:id="@+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="button three" />
</TableRow>
</TableLayout>
</LinearLayout>
简而言之,我在 TableRow 中有一个 ViewFlipper。ViewFlipper 正在缩小到其内容的大小,即使所有元素都指定了 fill_parent。在下面的屏幕截图中,ViewFlipper 具有灰色背景,而 TableRows 具有红色背景。