简体   繁体   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>  

i am trying to align the codes here in a row. 我正在尝试在这里对齐代码。 it being the relative layout as the parent and 3 linear layout as the child. 它是相对布局作为父级,而3个线性布局作为子级。 My java codes would generate text view and 2 edit text as the child of the linear layout and display it in a row. 我的Java代码将生成文本视图和2个编辑文本作为线性布局的子代,并将其显示在一行中。 however, it turned out vertical stacking on top of each other 然而,事实证明垂直堆叠是彼此叠加的

For each LinearLayout you should set the android:orientation attribute as horizontal . 对于每个LinearLayout您都应将android:orientation属性设置为horizontal See the code below: 请参见下面的代码:

android:orientation="horizontal"

Currently, your orientation is set to vertical so it is stacking on top of each other. 当前,您的方向设置为vertical因此彼此堆叠。

Set the LinearLayout orientation attribute from Vertical to Horizontal if u want it's child in a row. 如果您希望LinearLayout是连续的子级,请将LinearLayout方向属性从“ 垂直”设置为“ 水平”

android:orientation="horizontal"

I hope this is the answer that you want.. 我希望这是您想要的答案。

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

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