我有一个 LinearLayout,它应该包含一个项目列表(每个项目都是一个 LinearLayout)。问题是子项(LinearLayouts)没有显示在另一个下方:只有第一个可见。
这是我的 layout.xml:
<?xml version="1.0" encoding="utf-8"?>
<TextView
android:id="@+id/label_TextView"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="2"
android:paddingLeft="@dimen/form_label_padding_left"
android:text="" />
<LinearLayout
android:id="@+id/form_list_holder"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="8"
android:orientation="horizontal"
android:background="@color/form_list_background" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="@+id/label_TextView1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="2"
android:paddingLeft="@dimen/form_label_padding_left"
android:text="1" />
<EditText
android:id="@+id/edtx_input1"
android:layout_width="0dp"
android:layout_height="@dimen/form_input_height"
android:layout_marginTop="@dimen/form_edittext_margin_top"
android:layout_weight="5" />
<EditText
android:id="@+id/edtx_remark1"
android:layout_width="0dp"
android:layout_height="@dimen/form_input_height"
android:layout_marginTop="@dimen/form_edittext_margin_top"
android:layout_weight="3"
android:hint="@string/remarks"
android:visibility="invisible" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="@+id/label_TextView2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="2"
android:paddingLeft="@dimen/form_label_padding_left"
android:text="1" />
<EditText
android:id="@+id/edtx_input2"
android:layout_width="0dp"
android:layout_height="@dimen/form_input_height"
android:layout_marginTop="@dimen/form_edittext_margin_top"
android:layout_weight="5" />
<EditText
android:id="@+id/edtx_remark2"
android:layout_width="0dp"
android:layout_height="@dimen/form_input_height"
android:layout_marginTop="@dimen/form_edittext_margin_top"
android:layout_weight="3"
android:hint="@string/remarks"
android:visibility="invisible" />
</LinearLayout>
</LinearLayout>
你知道为什么会这样吗?我认为在 LinearLayout 中,如果当前行没有更多可用空间,则子项将显示在下一行。