I am developing an Android app. In my app, I want to use two RecyclerViews in one layout. I used LinearLayout to wrap up RecyclerViews because of this Stack Overflow question (Two RecyclerViews under each other in one layout).
As you can see the answer says, to use LinearLayout and set RecyclerViews height to wrap_content. I followed it. But when I run only one RecyclerView is appear and one is missing.
This is the screenshot:
As you can see, only on RecyclerView is appeared.
This is my XML layout:
<LinearLayout
android:orientation="vertical"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
android:scrollbars="vertical"
android:id="@+id/ai_rc_reviews"
android:layout_width="match_parent"
android:layout_height="wrap_content"></android.support.v7.widget.RecyclerView>
<android.support.v7.widget.RecyclerView
android:scrollbars="vertical"
android:id="@+id/ai_rc_reviews_2"
android:layout_width="match_parent"
android:layout_height="wrap_content"></android.support.v7.widget.RecyclerView>
</LinearLayout>
I tried this as well. Nothing appears on screen:
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:fillViewport="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<android.support.v7.widget.RecyclerView
android:id="@+id/ai_rc_reviews"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:background="@color/white"/>
<android.support.v7.widget.RecyclerView
android:id="@+id/ai_rc_reviews_2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white"/>
</LinearLayout>
</ScrollView>
How can I fix my code to use two RecyclerViews in single layout. Is there any better way to do it?