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