Difference between enterAlwaysCollapsed and exitUntilCollapsed scroll flags in coordinate layout
Asked Answered
C

2

8

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

Crone answered 12/8, 2017 at 9:3 Comment(0)
D
24

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

Digitize answered 12/8, 2017 at 9:14 Comment(3)
still unable to understandCrone
tell me in manner like what happens when we up and down scroll in both views and what is the difference in comparative tableCrone
medium.com/martinomburajr/…Digitize
P
10

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

Pulliam answered 15/12, 2017 at 19:5 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.