簡體   English   中英

如何在RelativeLayout中使用weightSum

[英]How to use weightSum in RelativeLayout

我剛剛創建了一個ID為rl1的相對布局我想為這個相對布局創建一個weightSum,值為2,以便在該布局中放置另一個2個相對布局,一個ID為fireID,另一個相對布局cartID,每個都取重量1我如何解決這個問題,這是我的xml文件

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    tools:context="abtech.waiteriano.com.waitrer.MenuActivity">
    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="?attr/colorPrimary"
        android:minHeight="?attr/actionBarSize" />
    <!--   <FrameLayout
       android:id="@+id/content_frame"
       android:layout_width="matc
        h_parent"
       android:layout_height="wrap_content"></FrameLayout>-->
    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:gravity="bottom"
        android:id="@+id/rl1"
        android:orientation="horizontal"
        android:weightSum="2">
        <FrameLayout
            android:id="@+id/content_frame"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_above="@+id/fireID">
        </FrameLayout>

        <RelativeLayout
            android:id="@+id/fireID"
            android:layout_width="fill_parent"
            android:layout_height="50dp"
            android:layout_weight="1"
            android:background="#ff6b6b"
            android:layout_alignParentBottom="true"
            android:layout_alignParentStart="true">
            <ImageView
                android:id="@+id/imageView1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerHorizontal="true"
                android:layout_centerVertical="true"
                android:layout_gravity="center"
                android:src="@drawable/fire" />
        </RelativeLayout>
        <RelativeLayout
            android:id="@+id/cartID"
            android:layout_width="fill_parent"
            android:layout_height="50dp"
            android:layout_weight="1"
            android:background="#ff6b6b"
            android:layout_alignParentBottom="true"
            android:layout_alignParentStart="true">
            <ImageView
                android:id="@+id/imageCart"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerHorizontal="true"
                android:layout_centerVertical="true"
                android:layout_gravity="center"
                android:src="@drawable/shoppingcart" />
        </RelativeLayout>
    </RelativeLayout>
</LinearLayout>

我們不能在RelativeLayout使用Weight。

暫無
暫無

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

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