简体   繁体   中英

Toolbar not collapsing with nested RecyclerView

I made collapsible toolbar on Activity, but there is one problem.

Screen contains RecyclerView that has multiple layout items, and one of them is another RecyclerView that has horizontal scroll. When main recycler is scrolled, toolbar doesn't expand or collapse when scroll started on that nested recycler, but on other views it's working as it should.

To make it easier to understand: when I first touch screen on position where there is nested RecyclerView and try to scroll up and down, there is no collapsing or expanding of toolbar.

Any idea what might be causing that issue and how to fix it?

I only needed to set recyclerView.setNestedScrollingEnabled(false) for the nested RecyclerView to work.

Thanks to Reddit user in this thread: Toolbar not collapsing with nested RecyclerView

For those who would like the same thing in Kotlin is:

recyclerView.isNestedScrollingEnabled = false

And for XML it is this property in RecyclerView but only for API 21 and higher:

android:nestedScrollingEnabled="false"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM