'Difference between enterAlwaysCollapsed and exitUntilCollapsed scroll flags in coordinate layout

I'm unable to understand difference between these two scroll flags applied to the toolbar or collapsing toolbar, when scroll up and scroll down



Solution 1:[1]

Update:

if you are still confused read the following blog: https://medium.com/martinomburajr/android-design-collapsing-toolbar-scrollflags-e1d8a05dcb02


Old:

1. enterAlways: The view will become visible when scrolling up. This flag is useful in cases when scrolling from the bottom of a list and wanting to expose the Toolbar as soon as scrolling up takes place.

enter image description here

Normally, the Toolbar only appears when the list is scrolled to the top as shown below:

enter image description here

2. enterAlwaysCollapsed: Normally, when only enterAlways is used, the Toolbar will continue to expand as you scroll down: enter image description here

Assuming enterAlways is declared and you have specified a minHeight, you can also specify enterAlwaysCollapsed. When this setting is used, your view will only appear at this minimum height. Only when scrolling reaches to the top will the view expand to its full height:

enter image description here

3. exitUntilCollapsed: When the scroll flag is set, scrolling down will normally cause the entire content to move:

enter image description here

Read more: https://medium.com/martinomburajr/android-design-collapsing-toolbar-scrollflags-e1d8a05dcb02

Solution 2:[2]

In case somebody's searching, I've made the description of all flags:

scroll

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

enterAlways

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

enterAlwaysCollapsed

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

exitUntilCollapsed

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

snap

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

Check out my blog post with an example code on GitHub

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 Sandeep Yohans