2016-12-18 1 views
0

이것은 내가 만든 XML 파일입니다. LinearLayout의 높이를 설정할 수 없습니다. 나는 수평으로 LinearLayout의 방향을 설정했고 layout_weight을 사용하여 LinearLayout의 높이를 설정했습니다.android app의 중첩 된 레이아웃이 작동하지 않습니다.

그러나 으로 TextView의 높이를 설정하면 작동하지 않습니다.

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:paddingBottom="16dp" 
    android:paddingLeft="16dp" 
    android:paddingRight="16dp" 
    android:paddingTop="16dp" 
    tools:context=".MainActivity" 
    android:weightSum="3"> 

    <LinearLayout 
     android:id="@+id/a" 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:layout_weight="1" 
     android:orientation="horizontal"> 
     <TextView 
      android:layout_width="0dp" 
      android:layout_height="match_parent" 
      android:layout_weight="1" 
      android:text="1"/> 
     <TextView 
      android:layout_width="0dp" 
      android:layout_height="match_parent" 
      android:layout_weight="1" 
      android:text="2"/> 
    </LinearLayout> 
    <LinearLayout 
     android:id="@+id/b" 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:layout_weight="1" 
     android:orientation="horizontal" 
     android:layout_below="@id/a"> 
     <TextView 
      android:layout_width="0dp" 
      android:layout_height="match_parent" 
      android:layout_weight="1" 
      android:text="3"/> 
     <TextView 
      android:layout_width="0dp" 
      android:layout_height="match_parent" 
      android:layout_weight="1" 
      android:text="4"/> 
    </LinearLayout> 
    <LinearLayout 
     android:id="@+id/c" 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:layout_weight="1" 
     android:orientation="horizontal" 
     android:layout_below="@id/b"> 
     <TextView 
      android:layout_width="0dp" 
      android:layout_height="match_parent" 
      android:layout_weight="1" 
      android:text="5"/> 
     <TextView 
      android:layout_width="0dp" 
      android:layout_height="match_parent" 
      android:layout_weight="1" 
      android:text="6"/> 
    </LinearLayout> 
</RelativeLayout> 
+1

"작동하지 않음"과 "작동하지 않음"은 무엇을 의미합니까? – Chris

답변

0

RelativeLayout (루트 레이아웃)은 가중치를 지원하지 않으므로 작동하지 않습니다. 최고 레벨 RelativeLayout을 으로 변경하고 vertical orientation으로 변경하면 정상적으로 작동합니다.

관련 문제