繁体   English   中英

相对和线性布局放置问题

[英]A relative and linear layout placing issue

<RelativeLayout
    android:id="@+id/layout"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:weightSum="1"
    >



<LinearLayout
    android:id="@+id/layout1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:layout_weight="0.3"
    >
</LinearLayout> 



<LinearLayout
    android:id="@+id/layout2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:layout_weight="0.35"
    android:layout_toRightOf="@+id/layout1"
    >
</LinearLayout>    


 <LinearLayout
    android:id="@+id/layout3"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:layout_weight="0.35"
    android:layout_toRightOf="@+id/layout2"
    >
</LinearLayout>  

我正在尝试在这里对齐代码。 它是相对布局作为父级,而3个线性布局作为子级。 我的Java代码将生成文本视图和2个编辑文本作为线性布局的子代,并将其显示在一行中。 然而,事实证明垂直堆叠是彼此叠加的

对于每个LinearLayout您都应将android:orientation属性设置为horizontal 请参见下面的代码:

android:orientation="horizontal"

当前,您的方向设置为vertical因此彼此堆叠。

如果您希望LinearLayout是连续的子级,请将LinearLayout方向属性从“ 垂直”设置为“ 水平”

android:orientation="horizontal"

我希望这是您想要的答案。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM