2017-03-06 7 views
-2

방금 ​​id가 ll1 인 상대 레이아웃을 만들었습니다.이 체중을 2로 만들려고합니다.이 레이아웃에 배치하는 상대 레이아웃은 다른 2 개의 상대적 레이아웃 중 하나이며, id는 fireID이고 다른 하나는 다른 것입니다. 그들 각각의 가중치 1을 상대 레이아웃 cartID는 어떻게이 내 XML이RelativeLayout에서 weightSum을 사용하는 방법

<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> 
+0

하면이 ... http://stackoverflow.com/questions/21144691/alternative-to-weightsum-in-relativelayout –

+3

를 참조하십시오 이 속성은 LinearLayout에서만 사용합니다 –

+0

첫 번째'RelativeLayout'을'LinearLayout'으로 바꿉니다 –

답변

4

우리는 RelativeLayout에 무게를 사용할 수없는 파일이 문제 을 silve 수 있습니다.

실제로 내가 모두에게 감사를 필요로 무엇입니까
+0

저는 이것을 실제로 알고 있습니다. 그러나 이것을 선형 레이아웃으로 변경하면이 선형 레이아웃이 레이아웃을 포함하는 페이지의 맨 아래에 표시 될 때 전체보기가 변경됩니다 @Asif Patel –

+0

id의 fireId 및 cartId의 RelativeLayout을 제거하고 alignParentBottom 특성을 사용하여 LinearLayout을 만들고 2 개의 ImageView를 그 안에 넣습니다. 각 ImageView에는 가중치 1이 있습니다. –

0

....

<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/bottom_panel"> 
     </FrameLayout> 

     <LinearLayout 
      android:id="@+id/bottom_panel" 
      android:orientation="horizontal" 
      android:layout_width="match_parent" 
      android:layout_height="50dp" 
      android:weightSum="2" 
      android:layout_alignParentBottom="true"> 
      <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> 
     </LinearLayout> 
    </RelativeLayout> 
</LinearLayout>