# Fixing RecyclerView nested scrolling in opposite direction

DevFeed: [Fixing RecyclerView nested scrolling in opposite direction](<https://devfeed.tech/articles/fixing-recyclerview-nested-scrolling-in-opposite-direction-25879.md>)

Original publisher: [Read original article](<https://bladecoder.medium.com/fixing-recyclerview-nested-scrolling-in-opposite-direction-f587be5c1a04?source=rss-54910f05af37------2>)

Author: Christophe Beyls

Published: 2020-03-26T15:24:30Z

Content type: tutorial

Language: en

Sources: [Stories by Christophe Beyls on Medium](<https://devfeed.tech/sources/stories-by-christophe-beyls-on-medium.md>)

Topics: [recyclerview](<https://devfeed.tech/topics/recyclerview.md>), [Android](<https://devfeed.tech/topics/android.md>), [User Interfaces](<https://devfeed.tech/topics/user-interfaces.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [android-app-development](<https://devfeed.tech/tags/android-app-development.md>), [androiddev](<https://devfeed.tech/tags/androiddev.md>), [interfaces](<https://devfeed.tech/tags/interfaces.md>), [layoutmanager](<https://devfeed.tech/tags/layoutmanager.md>), [nested-scroll](<https://devfeed.tech/tags/nested-scroll.md>), [recyclerview](<https://devfeed.tech/tags/recyclerview.md>)

## AI overview

This tutorial explains the nested-scrolling behavior of Android RecyclerView, focusing on layouts where horizontally scrolling lists are nested inside a vertically scrolling list. It describes why touch events can be intercepted by the parent and cause unexpected vertical scrolling, with examples such as Netflix-like video interfaces and Google Play Store layouts.

## Source excerpt

Photo by Tabl-trai under Creative Commons licenceand making ViewPager2 usable RecyclerView is one of the main building blocks of Android user interfaces today. It's more capable and flexible than its ListView predecessor but this also leads to more complexity and new problems. One core feature of RecyclerView is the externalization of its layout engine to components called LayoutManagers, which are no longer limited to vertical scrolling only. Most implementations allow to choose between horizontal and vertical scrolling and a LayoutManager could technically support both at the same time. RecyclerView also supports nested scrolling by implementing the NestedScrollingChild3 interface, which means it can cooperate with a parent view implementing NestedScrollingParent3 when both are configured to scroll in the same direction. In a nutshell, the scrolling child intercepts a scroll event and initiates a nested scroll in cooperation with the scrolling parent. Depending on its internal logic, the parent optionally consumes the scroll before or after the child, until they both reach their available scroll distance. A single scroll event may be consumed by both the parent and child with a seamless transition. For example, this mechanism is used when a RecyclerView is placed inside a CoordinatorLayout next to an app bar which will automatically slide up or collapse when a scroll gesture is initiated. Note that RecyclerView doesn't implement NestedScrollingParent3, so using a scrollable child inside a RecyclerView which scrolls in the same direction is not supported. However, Google currently provides a workaround to implement nested scrolling in a ViewPager2.The problem What about nested scrolling in the opposite direction? This should be supported out-of-the-box, since a vertical scrolling view is not supposed to intercept horizontal gestures and vice versa. In practice this works well with the legacy ViewPager which only scrolls horizontally, ignoring vertical gestures. But