CollapsingToolbar scrollflags in action!!!

Android Design — Collapsing Toolbar: ScrollFlags Illustrated

Martin Ombura Jr.
Published in
6 min readJan 31, 2018

--

In this section we will look at CollapsingToolbar scrollflags, combining scrollflags and some considerations when implementing them.

1. ScrollFlags

There are 5 scrollflags provided, these are
scroll, expandAlways, expandAlwaysCollapsed, snap, exitUntilCollapsed.

In order to use scrollflags in your CollapsingToolbar add the following property to your CollapsingToolbar.

app:layout_scrollFlags=”<select-flag-here> 

Now let’s set up a control without any flags to see how the CollapsingToolbar behaves.

Figure 1: Control scroll behavior with no scrollflags.

As you can see, from Figure 1, nothing special happens, the NestedScrollView scrolls freely under the CollapsingToolbar as the CollapsingToolbar stays in an expanded state. This is ideal if you have a View in your CollapsingToolbar that should always remain expanded and visible.

1.1 scroll

app:layout_scrollFlags=”scroll”
The scroll flag allows the NestedScrollView(i.e the underlying view encompassing all the content e.g text-paragraphs and image) to signal to…

--

--