2016-05-18 13 views
0

私は最大限スタックオーバーフローの回答を試しました。私の場合は何も働いていません。ここに私はRecyclerViewを持っています。私はrecyclerviewの高さを増やす必要があります項目(製品のレビュー)に依存します。しかし、私は何でも、それは私がxmlで与えた高さに固定されています。助けてください。RecyclerView高さはアイテムによって異なります

enter image description here

このビューのための私のXMLコード:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    style="@style/Layout_mw" 
    android:orientation="vertical"> 

      <LinearLayout 
       android:layout_width="match_parent" 
       android:id="@+id/recyclerLinear" 
       android:layout_height="200dp"> 

       <android.support.v7.widget.RecyclerView 
        android:id="@+id/reviewList" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:layout_margin="@dimen/fifteen_dp" 
        android:layout_marginLeft="12dp" 
        android:minHeight="100dp" 
        android:scrollbars="none" /> 
      </LinearLayout> 
     </LinearLayout> 


    </android.support.v7.widget.CardView> 


</LinearLayout> 

答えて

0

こんにちはそれはあなたがそれを固定しているため、高さが固定されていることが普通です。 あなたは、その内容に応じてダイナミックになりたいなら、あなたはこのように進めるべき:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    style="@style/Layout_mw" 
    android:orientation="vertical"> 

      <LinearLayout 
       android:layout_width="match_parent" 
       android:id="@+id/recyclerLinear" 
       android:layout_height="wrap_content"> 

       <android.support.v7.widget.RecyclerView 
        android:id="@+id/reviewList" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:layout_margin="@dimen/fifteen_dp" 
        android:layout_marginLeft="12dp" 
        android:minHeight="100dp" 
        android:scrollbars="none" /> 
      </LinearLayout> 
     </LinearLayout> 


    </android.support.v7.widget.CardView> 


</LinearLayout> 

設定した場合、私はもちろんのwrap_content (と固定の高さ200dpを置き換えますコードで高さを使用する必要がありますwrap_contentあなたのコードにも)。 希望に役立ちます。

関連する問題