

Let’s do a little test, open to Android Studio and create a project with the scrolling template, at the time of the writting is Scrolling Activity, without touching anything, we compile it and this is what we find:

SCROLL_FLAG_SNAP: Upon a scroll ending, if the view is only partially visible then it will be snapped and scrolled to it’s closest edge. SCROLL_FLAG_SCROLL: The view will be scroll in direct relation to scroll events. SCROLL_FLAG_EXIT_UNTIL_COLLAPSED: When exiting (scrolling off screen) the view will be scrolled until it is ‘collapsed’. SCROLL_FLAG_ENTER_ALWAYS_COLLAPSED: An additional flag for ‘enterAlways’ which modifies the returning view to only initially scroll back to it’s collapsed height. SCROLL_FLAG_ENTER_ALWAYS: When entering (scrolling on screen) the view will scroll on any downwards scroll event, regardless of whether the scrolling view is also scrolling. There are some Github repositories with different implementations at the end of this article.

Anyway, my recommendation is to always play by example. These are all the available parameters acording Google Developers docs. The LinearLayout which contains the title and subtitle will be shown always that user scrolls up, ( enterAlways value), the TabLayout will be always visible because we don’t have any flag on it.Īs you can see ,the real power of an AppbarLayout is caused by the proper management of the different scroll flags in their views. That means that animations will always hide or expand its entire height. The value: snap, allows us to avoid falling into mid-animation-states. The value: scroll in this case it’s present in almost all views, if we don’t specify it, childs of the AppbarLayout will remain static allowing the scrollable content slide behind it. We can manage the behavior of AppbarLayout direct childs with the parameter: layout_scrollFlags. A LinearLayout with a title and a subtitle, and, finally, a TabLayout with some tabs. The AppBarLayout in this case is the blue view, placed under the collapsing image, it contains a Toolbar. The CoordinatorLayout has only three childs: an AppbarLayout, a scrolleable view, and an anchored FloatingActionButton.īasically, an AppBarLayout is a LinearLayout with steroids, their children are placed vertically, with certain parameters children can manage their own behavior when content is scrolled.
