Android Design — Collapsing Toolbar: ScrollFlags Illustrated
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.
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…