1

i want to make a layout with multiple RecyclerViews like this

<ScrollView
<LinearLayout << content here
<android.support.v7.widget.RecyclerView
<LinearLayout << content here
<android.support.v7.widget.RecyclerView
<LinearLayout << content here
<android.support.v7.widget.RecyclerView
</ScrollView>

but the problem in this layout that the RecyclerView is not recycling item because its inside a scroll view ,,, my question is How do other apps achieve this effect of multiple vertical lists ? How can i scroll content out ? what are the options i can do ?

Note : RecyclerViews will have different LayoutMnager

Saef Myth
  • 287
  • 8
  • 19

3 Answers3

0

You can use NestedScrollView. Don't use scrollview.. Give also "recyclerView.setNestedScrollingEnabled(false)". It will solve your issue

Viswa Sundhar
  • 121
  • 3
  • 16
0

If all recyclerviews scroll vertically you can just use GridLayoutManager with different span counts (see link) and one recyclerview with different view types (see link)

Fatih Santalu
  • 4,641
  • 2
  • 17
  • 34
  • this is possible but its very limted when you have a lot of defrrent items ,,, and its very time consuimg – Saef Myth Jul 17 '17 at 19:38
0

The trick here is to create a 'mother' RecyclerView that hosts other recycler views. Make you Items like this :

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical">

    <TextView
        android:id="@+id/your_content"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />

    <android.support.v7.widget.RecyclerView xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/item_rv"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"/>
</LinearLayout>

Then make an appropriate ViewHolder :

public static class ViewHolder extends RecyclerView.ViewHolder {
    private TextView textView;
    private RecyclerView recyclerView;

    public ViewHolder(View itemView) {
        super(itemView);
        textView = (TextView) itemView.findViewById(R.id.your_content);
        recyclerView = (RecyclerView) itemView.findViewById(R.id.item_rv);
    }
}

Now, setup the RecylerView when Binding :

public void onBindViewHolder(ViewHolder viewHolder, int i) {
    viewHolder.textView.setText("This is content " + i);
    viewHolder.recyclerView.setLayoutManager(new GridLayoutManager(activity, 2, LinearLayoutManager.HORIZONTAL, false));
    viewHolder.recyclerView.setAdapter(new MyAdapter());
}
Mehdi
  • 65
  • 4