Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 984
blackHawk Avatar asked Aug 12 '17 09:08

blackHawk


People also ask

What is layout_scrollFlags?

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 the CollapsingToolbar that it is in a scrolling state.

How do I disable scrolling in collapsing toolbar layout Android?

How do I disable scrolling in collapsing toolbar layout Android? The solution is simple, we just need to set the app:scrimAnimationDuration=”0" in our collapsing toolbar layout like the below code snippet. Now just run the code and see the results, you will see then there will be no fading animation anymore.

What is collapsing toolbar Android?

Android CollapsingToolbarLayout is a wrapper for Toolbar which implements a collapsing app bar. It is designed to be used as a direct child of a AppBarLayout. This type of layout is commonly seen in the Profile Screen of the Whatsapp Application.


2 Answers

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

like image 115
ILYAS_Kerbal Avatar answered Oct 02 '22 05:10

ILYAS_Kerbal


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

like image 35
lomza Avatar answered Oct 02 '22 05:10

lomza