i have 2 simple recycler views want show directly below each other. here layout:
<relativelayout android:layout_width="match_parent" android:layout_height="match_parent"> <include layout="@layout/drawer_view_header" android:id="@+id/navigation_header"/> <android.support.v7.widget.recyclerview android:layout_below="@id/navigation_header" android:id="@+id/friends_list" android:layout_width="match_parent" android:layout_height="wrap_content"/> <android.support.v7.widget.recyclerview android:layout_below="@id/friends_list" android:id="@+id/followers_list" android:layout_width="match_parent" android:layout_height="wrap_content"/> </relativelayout>
i have navigationheader
above first recycler view called friends_list
works fine, , can see friends_list
recycler view has android:layout_height="wrap_content"
followers_list
recycler view doesn't seem show though contents of friends_list
shown. ideas why not showing up? thanks!
while above answers work don't preserve wrap content behavior of recycler view need use nestedscrollview
.
for eg need this:-
<android.support.v4.widget.nestedscrollview android:layout_width="match_parent" android:layout_height="match_parent"> <relativelayout android:layout_width="match_parent" android:layout_height="match_parent"> <include layout="@layout/drawer_view_header" android:id="@+id/navigation_header"/> <android.support.v7.widget.recyclerview android:layout_below="@id/navigation_header" android:id="@+id/friends_list" android:layout_width="match_parent" android:layout_height="wrap_content"/> <android.support.v7.widget.recyclerview android:layout_below="@id/friends_list" android:id="@+id/followers_list" android:layout_width="match_parent" android:layout_height="wrap_content"/> </relativelayout> </android.support.v4.widget.nestedscrollview>
or may use linearlayout
vertical alignment in nestedscrollview
.
*note:- work recycler view above 23.2.0
compile 'com.android.support:recyclerview-v7:23.2.0'