Android – Fixed header with CoordinatorLayout showing shadow when scrolling

androidandroid-coordinatorlayoutcoordinator-layout

The classic coordinator layout gives you the following [source]:
coordinator layout

However, I don't want the top header views to scroll until they "become" a toolbar pinned at the top, with a shadow below. I want them all fixed (or pinned) but to show the shadow only the nested scroll view starts to scroll under the pinned ones. Something like the main app drawer on Marshmallow devices, where the "search bar" becomes pinned and the list of apps scroll under it.

Hope I made myself clear. Is there any easy way I could achieve that without listening for scroll events and handling this manually?

EDIT

Here is what I'm trying to achieve:

App drawer. Notice on the right image how there is now a shadow below the list of apps because the user scrolled the list.

Thank you!

Best Answer

This is exactly what you are looking for: HideOnScroll

Related Topic