Reputation: 1884
I am trying to learn about CollapsingToolbarLayout which has some value set to scrollFlags
to control how the view within it will collapse. Can anybody clearly demarcate the difference between these flags:
How do these work when we set these flags to both Toolbar and CollapsingToolbarLayout.
Upvotes: 7
Views: 4175
Reputation: 9716
I've made a table to clear things up. Also wrote quite an informative blog post with an example code on GitHub :)
Scroll Up: the view becomes visible when the layout's been scrolled all the way up Scroll Down: the view scrolls with the rest of the content like it's a part of it; will hide if the layout's height is bigger than the screen's one
Scroll Up: the view becomes visible on every scroll up action, even if there's still a lot of content to scroll up Scroll Down: the view scrolls with the rest of the content like it's a part of it; will hide if the layout's height is bigger than the screen's one
Scroll Up: the collapsed version of the view (e.g. Toolbar
) becomes visible on every scroll up action, and it expands (e.g. Toolbar
with an ImageView
) only when scrolled all the way up
Scroll Down: the view collapses and then hides, if the layout's height is bigger than the screen's one
Scroll Up: the view is always visible, provided its height is > 0 and the expanded version (e.g. Toolbar with an ImageView) will become visible when scrolled all the way up
Scroll Down: the view scrolls with the rest of the layout's content, but only till its collapsed state (hence - "exit until collapsed"), so in case of a Toolbar
with a fixed height, it will always be visible on the top
Scroll Up AND Down fast scrolls up or down based on how much of the view is visible - if more than 50% - the view will scroll down, showing itself, if less - the view will hide; used with other flags as a further customization
Upvotes: 6
Reputation: 313
From Antonio Leiva's blog here, the flags work like this:
scroll: This means it will scroll while scrolling the targeted view (our recycler view in this case).
enterAlways: When we scroll up, the view will immediately reappear.
enterAlwaysCollapsed: if the view has a collapsed mode, it will reappear collapsed when scrolling up.
exitUntilCollapsed: it won´t exit from the screen until the view is collapsed.
Upvotes: 3