0

2つのLinearLayoutsをRelativeLayout(rootelement)に配置しようとしています。 1行しか見ることができません。 Layout_below **では、2番目のLinearlayoutを最初のLinearLayoutの下に配置する必要はありませんか?relativelayoutで線形レイアウトをラップします

どうしたのですか? LinearLayout自体がViewGroupなのではありますか?それはあなたのためだ

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" android:layout_height="match_parent"> 

<LinearLayout 
    android:id="@+id/addon1_row" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="horizontal"> 

    <ImageView 
     android:id="@+id/weapon1_id" 
     android:layout_width="100dp" 
     android:layout_height="26dp" 
     android:src="@mipmap/weapon1" 
     android:adjustViewBounds="true" 
     /> 

    <ImageView 
     android:layout_width="100dp" 
     android:layout_height="26dp" 
     android:src="@mipmap/buy_button" 
     android:adjustViewBounds="true" 
     /> 
</LinearLayout> 

<LinearLayout 
    android:id="@+id/addon2_row" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="horizontal" 
    android:layout_below="@+id/addon1_row"> 

    <ImageView 
     android:id="@+id/weapon2_id" 
     android:layout_width="100dp" 
     android:layout_height="26dp" 
     android:src="@mipmap/weapon2" 
     android:adjustViewBounds="true" 
     /> 

    <ImageView 
     android:layout_width="100dp" 
     android:layout_height="26dp" 
     android:src="@mipmap/buy_button" 
     android:adjustViewBounds="true" 

     /> 
</LinearLayout> 


</RelativeLayout> 
+1

に設定"match_parent"にリニアレイアウトの両方の高さを設定しています。しかし、LinearLayoutsを使わずに単一のRelativeLayoutを使うか、GridViewを使って(LinearLayoutsを追加しないで)、すべてを(パフォーマンスのために)最適化します。 –

+1

@Rotwang、ありがとう、私はそれを考慮する – java

答えて

1

は、ちょうどあなたが本当にあなたの現在の配置与えRelativeLayoutを、必要としない"wrap_content"

<LinearLayout 
    android:id="@+id/addon1_row" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" <== Here 
    android:orientation="horizontal"> 


<LinearLayout 
    android:id="@+id/addon2_row" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" <== Here 
    android:layout_below="@+id/addon1_row" 
    android:orientation="horizontal"> 
関連する問題