簡體   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