Nested Recyclerview scrolls by itself

Ah, I've been struggling for a fix. The solution is very simple actually. As a reference for me (and anyone else facing the same issue in the future), I just have to setFocusable() in the child view's rv to false, and it doesn't focus to that view anymore when the fragment is visible.

In my case, I have to set it programmatically after data has been loaded from an API.


We have a similar problem. We have a vertical RecyclerView. Each item of this vertical RecyclerView contains an horizontal RecyclerView, like in the Android TV app.

When we upgraded the support libs from 23.4.0 to 24.0.0 the automatic scroll suddenly appeared. In particular, when we open an Activity and we then go back, the vertical RecyclerView scrolls up so that the current horizontal RecyclerView row does not get cut and the row is displayed completely.

There is an easy fix. Add this to your outer/parent RecyclerView:

android:descendantFocusability="blocksDescendants"

I've found the solution in this questions:

  • nested scrollview + recyclerview, strange autoscroll behaviour
  • Android prevent nested recyclerview from automatically repositioning

Additionally, I've found another solution, which also works. In our case the vertical RecyclerView is contained inside a FrameLayout. If I add android:focusableInTouchMode="true" to this FrameLayout, the problem goes away.

By the way, there is also an open issue on the AOSP.


After a long search i got my eyes on parameter reverseLayout that was set to true. I replaced

horizontalRV.setLayoutManager(
    new LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, true));

with

horizontalRV.setLayoutManager(
    new LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false));

Try this android:descendantFocusability="blocksDescendants". It solved the problem for me.