Nested RecyclerView scrolling issue

recyclerview not scrolling smoothly android
recyclerview inside recyclerview scroll issue
nested scrollview not scrolling smoothly in android
android nested recyclerview performance
recyclerview inside recyclerview not scrolling smoothly
recyclerview inside nestedscrollview not recycling
nested recyclerview scroll position
recyclerview inside viewpager not scrolling

In my application I have vertical parent RecyclerView with few horizontal childs inside its ViewHolders. But I have pretty annoying scrolling issue - after I scroll parent RV vertically I want to scroll one of my child RVs but parent just intercepts all motion events until I remove my finger from screen and then put it back. Here's the example of this annoying behaviour.

https://i.imgur.com/dPtmAXD.gif

I tried every solution from this question - Nested RecyclerView. How to prevent parent RecyclerView from getting scrolled while child RecyclerView is scrolling?

Nothing works for me.

It looks like Google Play Market has the same RV hierarchy, but ofc scroll is perfectly fine. I tried to implement few solutions from other topics, but nothing works as intended.

I don't know what code should I post, but here's my Parent RV's ViewHolder example with nested RV.

private class UserEventsViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
        private RecyclerView rvUserEvents;
        private HomeUserEventsRVAdapter rvAdapter;

        public UserEventsViewHolder(View v) {
            super(v);

            rvUserEvents = v.findViewById(R.id.rv_user_events);
            rvUserEvents.setLayoutManager(new LinearLayoutManager(itemView.getContext(), LinearLayoutManager.HORIZONTAL, false));
            rvUserEvents.setNestedScrollingEnabled(false);
            rvUserEvents.setRecycledViewPool(viewPool);
            rvAdapter = new HomeUserEventsRVAdapter(presenter);
            rvUserEvents.setAdapter(rvAdapter);

            v.findViewById(R.id.btn_all_user_events).setOnClickListener(this);
        }

        private void bind(UserItemViewModel userItem) {
            rvAdapter.updateAdapter(userItem);
        }

        @Override
        public void onClick(View v) {
            switch (v.getId()) {
                case R.id.btn_all_user_events:
                    presenter.openUserEventsList();
                    break;
            }
        }
    }

EDIT: XML code for my activity

<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/cl_root"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white">

<android.support.design.widget.AppBarLayout
    android:id="@+id/ab_layout"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
    android:fitsSystemWindows="true">

    <android.support.design.widget.CollapsingToolbarLayout
        android:id="@+id/collapsing_toolbar"
        android:layout_width="match_parent"
        android:layout_height="190dp"
        app:layout_scrollFlags="scroll|exitUntilCollapsed"
        android:fitsSystemWindows="true"
        app:contentScrim="@android:color/white"
        app:expandedTitleMarginStart="48dp"
        app:expandedTitleMarginEnd="64dp">

        <ImageView
            android:id="@+id/iv_pic"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:scaleType="centerCrop"
            android:src="@drawable/ic_home_screen_background"
            android:fitsSystemWindows="true"
            app:layout_collapseMode="parallax"
            app:layout_collapseParallaxMultiplier="0.5"/>

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:elevation="7dp"
            android:theme="@style/ToolbarTheme"
            app:layout_collapseMode="pin"/>
    </android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>

<android.support.v4.widget.SwipeRefreshLayout
    android:id="@+id/sr_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_marginTop="-6dp"
    app:layout_behavior="@string/appbar_scrolling_view_behavior">

    <android.support.v7.widget.RecyclerView
        android:id="@+id/rv_results"
        android:clipToPadding="false"
        android:scrollbars="vertical"
        android:scrollbarThumbVertical="@color/orange_juice_80"
        android:scrollbarSize="2dp"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@drawable/shape_rounded_top_grey"
        android:fitsSystemWindows="true" />
</android.support.v4.widget.SwipeRefreshLayout>

<android.support.design.widget.FloatingActionButton
    android:id="@+id/fab_add"
    android:layout_width="56dp"
    android:layout_height="56dp"
    android:layout_marginEnd="15dp"
    app:backgroundTint="@color/dark_background"
    app:layout_anchor="@id/rv_results"
    app:layout_anchorGravity="top|right|end"
    app:layout_scrollFlags="scroll|exitUntilCollapsed"
    app:srcCompat="@drawable/ic_vector_plus_white" />

You disabled the nested scrolling of RecyclerView in this line

rvUserEvents.setNestedScrollingEnabled(false);

You need to replace this line with below to scrolling work properly

ViewCompat.setNestedScrollingEnabled(rvUserEvents,true);

Scroll issue with nested RecyclerView � Issue #141 � airbnb/epoxy , Whenever the page loads, the root RecyclerView with the Epoxy adapter scrolls down until the nested RecyclerView is visible. When I switch� In my application I have vertical parent RecyclerView with few horizontal childs inside its ViewHolders.But I have pretty annoying scrolling issue - after I scroll parent RV vertically I want to scroll one of my child RVs but parent just intercepts all motion events until I remove my finger from screen and then put it back.

<androidx.recyclerview.widget.RecyclerView
     android:id="@+id/recyclerView"
     android:layout_width="match_parent"
     android:descendantFocusability="blocksDescendants"
     android:layout_height="wrap_content"
     android:scrollbars="none" />

Use android:descendantFocusability="blocksDescendants" attribute inside nested recyclerview

Improving scrolling behavior of nested RecyclerViews, Problem 1. If you use a standard RecyclerView, you may encounter this behavior during scrolling: As you can see in the video, if you try to scroll a nested RecyclerView while the parent is still settling the scroll, you won't be able to do it easily. Now what kinda problem occurred when we used nestedScrollView and put recyclerView inside nestedScrollView, it scrolls at various speeds depending on gestures. The scrolling feature will not be smooth.

 recyclerView.setNestedScrollingEnabled(false);

RecyclerView within NestedScrollView Scrolling Issue, So to fix this issue all you have to do after setting your adapter. put this line ViewCompat.setNestedScrollingEnabled(recyclerView, false);. RecyclerView now has a nestedScrollBy method that allows programmatic scrolling that cooperates with nested scrolling: Version 1.2.0-alpha02. April 1, 2020. androidx.recyclerview:recyclerview:1.2.0-alpha02 is released. Version 1.2.0-alpha02 contains these commits.

Fixing RecyclerView nested scrolling in opposite direction, That's why I consider it a bug. Introducing ViewPager2. At this point you may think that nested RecyclerView s are rare so the severity of this issue� When the user swipes the side-wise the inner RecyclerView recycles the views and gives you a smooth scroll. But this is not the case when the user scrolls vertically. Each of the views of the inner RecyclerView is inflated again. This is because each of the the nested RecyclerViews has a view pool of its own.

Nested Recycler View Scrolling Issue, I have used Recycler View Inside Nested Scroll View(which is within CoordinatorLayout): <android.support.v4.widget.NestedScrollView android:id="# +id/scroll"� Thus, each item resets to its original state from creation as soon as you scroll away from the view. And the issue with nested RecyclerView carousels is that each carousel loses the index that was scrolled to originally.

Is a RecyclerView of RecyclerViews a good idea? : androiddev, It looks like a lot of apps are implementing a RecyclerView of RecyclerView, but I am for several reasons) or to make another (nested) RecyclerView inside card. nesting recyclerviews that scroll in the same direction is generally a bad idea,� I had the same issue but in the end I moved my textview to be a headerview within the recyclerview, made the recyclerview a direct child of the coordinator layout and deleted the nested scroll view. Then all my problems were gone.

Comments
  • Your link to the GIF has expired. My Play Store exhibits the behavior that you are seeing in your app. Where, specifically, do you see the alternate behavior in the Play Store app?
  • In the Play Store app you can scroll the parent RV fast, then just put your finger on one of the childs while parent's still scrolling - this action stops parent vertical scrollin and now you can scroll child straight away. As i said, In my application if I scroll parent vertical RV fast I have to put my finger on screen once just to stop parent scrolling, then I have to get my finger off the screen and put it back to scroll child. If I'm tryng to child with my first touch, parent intercepts swipes. @Cheticamp
  • Updated gif link @Cheticamp
  • Any progress? Any solution? I have same problem.
  • From what I understand you need to play around with MotionEvents passing down between RecyclerViews. I could probably work on a solution if you can provide a Minimum Verifiable Example.
  • Well, I did this because I'm using collapsingToolbarLayout with my parent RV. If I remove this line collapsingToolbarLayout will never collapse again.
  • I tried your solution - doesn't work, same behaviour.