Search code examples
androidandroid-layoutandroid-recyclerviewandroid-coordinatorlayout

Scrolling in multiple directions with nested RecyclerViews + AppBarLayout


I've been having trouble with AppBarLayout behavior. I have a basic setup of an AppBarLayout to hide the Toolbar whenever I scroll and that works as expected, however, because my vertical scrolling view is composed of multiple horizontal scrolling views whenever I start the vertical scroll by touching on any of the horizontal scrolling views the AppBarLayout won't catch the scroll. I've been debugging and the layoutDependsOn or the onNested[Pre]Scroll are not triggered in the AppBarLayout's behavior.

However, if I start the scroll on any area which isn't a horizontal recycler it triggers the AppBarLayout's behavior. Flinging works regardless of the starting point of the touch.

How can I fix that?

My structure is as follows:


Solution

  • So after further investigation here on SO I've found this https://stackoverflow.com/a/34318170/7913860 which solved my issue.

    The key is to have android:nestedScrollingEnabled="false" on the inner recyclers