我应该使用哪种布局/我将如何在没有重叠的情况下将布局堆叠在一起?
我试图在一个线性布局中包含两个相对布局。相对布局需要相互垂直堆叠。我尝试了以下代码,但没有任何运气。有什么建议吗?
<LinearLayout
android:id="@+id/headerquickmatch"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<RelativeLayout
android:id="@+id/matchnameheader"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<TextView
.../>
<EditText
... />
</RelativeLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/matchnameheader" >
<TextView
... />
<EditText
... />
<Button
... />
</RelativeLayout>
</LinearLayout>发布于 2013-09-24 04:38:43
将android:orientation="vertical"放在父线性布局上。因此,所有的子布局(相对布局)将自动垂直堆叠。对每个布局组件使用不同的id。
发布于 2013-09-24 04:48:35
<LinearLayout
android:id="@+id/headerquickmatch"
android:layout_width="fill_parent"
*android:orientation="vertical"*
android:layout_height="fill_parent">
<RelativeLayout
android:id="@+id/matchnameheader"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<TextView
.../>
<EditText
... />
</RelativeLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/matchnameheader" >
<TextView
... />
<EditText
... />
<Button
... />
</RelativeLayout>
</LinearLayout>请将orientation=vertical添加到顶部父线性layout.so中,所有子布局都将显示在堆叠布局中。
我希望这对你有用。
https://stackoverflow.com/questions/18973014
复制相似问题