In my app, i'm using AppBarLayout + CollapsingToolbarLayout + CoordinatorLayout. Basically, the appbarlayout has a header with parallax, and a recyclerView with scrolling appbar behavior. When scrolling the recyclerView, i added a scrollListener
RecyclerView.OnScrollListener()
and checked for
recyclerView.computeVerticalScrollOffset()
to collapse or expand the appbarLayout when the RecyclerView.SCROLL_STATE_IDLE. Basically, this would collapse/expand the appbarlayout when the user ends the scroll, in order to prevent half-states of the appbarlayout.
This works if the user scrolls by touching inside the recyclerView boundaries. If the user scrolls by touching the appbarlayout expanded header, this listener is never called. How can i workaround this?
It turns out this solution is no longer needed. CollapsingToolbarLayout has an attribute app:layout_scrollFlags="scroll|exitUntilCollapsed|snap
which does exactly the same, it prevent 'half states', it either collapses or expand.