簡體   English   中英

如何堆疊兩個LinearLayouts?

[英]How to stack two LinearLayouts?

我在堆疊兩個線性布局(顯示塊級別)時遇到問題。 相反,它們並存。

任何幫助表示贊賞。

這是問題所在的XML。 Stack1Stack2是所討論的兩個LinearLayouts的ID。 我用...簡化了其他線性布局,以節省空間。

<FrameLayout
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:id="@+id/frame"
    android:layout_weight="0.8">

     <LinearLayout
     ...></LinearLayout>

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom"
        android:orientation="horizontal">

        <LinearLayout
            android:orientation="horizontal"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:gravity="center"
            android:id="@+id/Stack1">

            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:textColor="#ffffff"
                android:gravity="center"
                android:layout_marginTop="3dp"
                android:layout_marginBottom="1dp" />
        </LinearLayout>

        <LinearLayout
            android:orientation="horizontal"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:gravity="center"
            android:id="@id+/Stack2>

            <ImageButton
                android:layout_width="45dp"
                android:layout_height="45dp"
                android:background="#00010102"
                android:layout_margin="10dp"
                android:scaleType="fitCenter" />

            <ImageButton
                android:layout_width="45dp"
                android:layout_height="45dp"
                android:background="#00010102"
                android:layout_margin="10dp"
                android:scaleType="fitCenter" />

            <ImageButton
                android:layout_width="45dp"
                android:layout_height="45dp"
                android:background="#00010102"
                android:layout_margin="10dp"
                android:scaleType="fitCenter" />

            <ImageButton
                android:layout_width="45dp"
                android:layout_height="45dp"
                android:background="#00010102"
                android:layout_margin="10dp"
                android:scaleType="fitCenter" />

            <ImageButton
                android:layout_width="45dp"
                android:layout_height="45dp"
                android:background="#00010102"
                android:layout_margin="10dp"
                android:scaleType="fitCenter" />
        </LinearLayout>
    </LinearLayout>

</FrameLayout>

作為Stack1和Stack2的父級的LinearLayout被定義為水平。 將其垂直放置,以防止其並排放置。

暫無
暫無

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

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