2016-05-24 3 views
1

RecyclerViewの子としてRecyclerViewを使用していますが、2番目のRecyclerViewにデータを追加すると何も表示されません。私が第2の高さを設定したとき、それはその内容を示す(例えば100dp)と言うべきです。別のRecyclerViewの内部で使用すると、RecylerViewの高さが塗りつぶされない

どのように問題を解決する必要がありますか?

-main XML

<android.support.v7.widget.RecyclerView 
     android:id="@+id/recycler_view1" 
     android:layout_margin="@dimen/activity_horizontal_margin" 

     android:layout_width="match_parent" 
     android:layout_height="match_parent"/> 

    <ProgressBar 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:id="@+id/progressBar3" 
     android:visibility="gone" 
     android:background="#1E88E5" 
     android:layout_alignParentTop="true" 
     android:layout_centerHorizontal="true" /> 

</RelativeLayout> 
  • 項目のXML

    <RelativeLayout 
        android:clickable="true" 
        android:id="@+id/lla2" 
        android:layout_width="match_parent" android:layout_height="match_parent"> 
    
        <TextView 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:textAppearance="?android:attr/textAppearanceLarge" 
         android:text="Medium Text" 
         android:id="@+id/textView3" 
         android:layout_alignParentTop="true" 
         android:layout_marginTop="@dimen/activity_horizontal_margin" 
         android:layout_marginBottom="@dimen/activity_horizontal_margin" 
         android:layout_alignRight="@+id/view13" 
         android:layout_alignEnd="@+id/view13" 
         android:layout_toEndOf="@+id/ib2" 
         android:layout_alignLeft="@+id/view13" 
         android:layout_alignStart="@+id/view13" 
         android:layout_toRightOf="@+id/ib2" /> 
    
        <View 
         android:layout_width="match_parent" 
         android:layout_height="1dp" 
         android:background="@android:color/darker_gray" 
         android:id="@+id/view13" 
         android:layout_margin="@dimen/activity_horizontal_margin" 
         android:layout_below="@+id/textView3" 
         android:layout_toRightOf="@+id/ib2" 
         android:layout_toEndOf="@+id/ib2" /> 
    
        <android.support.v7.widget.RecyclerView 
         android:id="@+id/recycler_view6" 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content" 
         android:layout_marginRight="@dimen/activity_horizontal_margin" 
         android:layout_marginEnd="@dimen/activity_horizontal_margin" 
         android:layout_marginBottom="@dimen/activity_horizontal_margin" 
         android:layout_alignLeft="@+id/textView3" 
         android:layout_alignStart="@+id/textView3" 
         android:layout_below="@+id/view13" /> 
    
    
        <ImageButton 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:background="?selectableItemBackground" 
         android:src="@drawable/ic_more_vert_black_24dp" 
         android:alpha="0.5" 
         android:id="@+id/ib2" 
         android:layout_marginTop="@dimen/activity_horizontal_margin" 
         android:layout_alignTop="@+id/textView3" 
         android:layout_alignParentLeft="true" 
         android:layout_alignParentStart="true" /> 
    
        <ImageButton 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:background="?selectableItemBackground" 
         android:src="@drawable/note" 
         android:layout_marginTop="@dimen/activity_horizontal_margin" 
         android:id="@+id/imageButton" 
         android:alpha="0.1" 
         android:layout_below="@+id/ib2" 
         android:layout_alignParentLeft="true" 
         android:layout_alignParentStart="true" /> 
    
        <ImageButton 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:background="?selectableItemBackground" 
         android:src="@drawable/bookmark" 
         android:alpha="0.5" 
         android:id="@+id/imageButton2" 
         android:layout_below="@+id/imageButton" 
         android:layout_alignParentLeft="true" 
         android:layout_alignParentStart="true" /> 
    
    
    </RelativeLayout> 
    

+0

xmlを投稿してください。 –

+0

@LucasPaolillo xmlを投稿しました – Ali

答えて

0

にいますLinearLayoutマネージャを使用していますか?もしそうなら、それはあなたの問題です。最近までwrap_contentで高さを測定するのはそれほど優れていませんでした。

yourLinearLayoutManager.setAutoMeasureEnabled(true);

自動測定を可能にし、それがwrap_contentで動作するようになります:あなたはrecyclerviewライブラリーの比較的新しいバージョンを使っている(とLinearLayoutManagerを使用している)場合は、これに電話をかけます。また、これはネストされたrecyclerviewなので、ネストされたスクロールを有効にすることを忘れないでください。

+0

GridLayoutManagerを使用しています。gridLayoutManager = new GridLayoutManager(context、items.get(0).getTranslate()。size()> 1?2:1); – Ali

+0

GridLayoutManagerには、autoMesureオプトインAPIもあります。私は先に進み、あなたのネストされたrecyclerviewのレイアウトマネージャーでそれを呼び、それがあなたの問題を修正するかどうかを見ます。最初の返信と同じ方法で呼び出されます。 – craya

+0

私はテストしましたが、何も起こりませんでした。 – Ali

関連する問題