2016-12-18 14 views
0

これは作成したXMLファイルです。 LinearLayoutの身長を設定できません。私はLinearLayoutの向きを水平に設定しました。layout_weightを使用して、高さをLinearLayoutに設定しました。アンドロイドアプリのネストされたレイアウトが機能していません

しかし、TextViewの高さをmatch_parentに設定しても機能しません。

<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に変更しても問題ありません。

関連する問題