簡體   English   中英

如何使LinearLayout(或任何其他布局)在右側堆疊子級

[英]How to make LinearLayout (or any other layout) to stack childs on the right side

我在運行時向我的LinearLayout添加新視圖。 我希望它們堆疊在布局的右側。

圖片時鍾圖標堆積在左側,因此與我想要的相反。 是否可以使它們堆疊在隱藏的LinearLayout的右側? (它可以是任何其他布局,如果可以提供我想要的,則不僅可以是線性布局)

在此處輸入圖片說明

像這樣嗎

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:gravity="right"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true" >

    <Button
        android:id="@+id/button3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Button" />

    <Button
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Button" />

    <Button
        android:id="@+id/button2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Button" />

</LinearLayout>

藍線是所選的線性布局:

藍線是所選的線性布局

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM