Material design layout_scrollFlags meanings

后端 未结 1 1652
南旧
南旧 2021-01-30 08:51

I find out that we can use cool flags that scroll both toolbar and even content by using layout_scrollFlags. In my case, I have a layout like this:

         


        
相关标签:
1条回答
  • 2021-01-30 08:59

    I don't know if my answer will still be relevant, but nevertheless. Actually docs are quite enough to understand things going around, you just need to play a little bit around.
    The scroll flag used within the attribute app:layout_scrollFlags must be enabled for any scroll effects to take into effect. This flag must be enabled along with enterAlways, enterAlwaysCollapsed, exitUntilCollapsed, or snap:

    • 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.
    • enterAlwaysCollapsed: Normally, when only enterAlways is used, the Toolbar will continue to expand as you scroll down.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
    • exitUntilCollapsed: When the scroll flag is set, scrolling down will normally cause the entire content to move.By specifying a minHeight and exitUntilCollapsed, the minimum height of the Toolbar will be reached before the rest of the content begins to scroll and exit from the screen
    • snap: Using this option will determine what to do when a view only has been partially reduced. If scrolling ends and the view size has been reduced to less than 50% of its original, then this view to return to its original size. If the size is greater than 50% of its sized, it will disappear completely.

    Please have a look at this blog it should be really helpful.

    Update: Also there is another article (edit: now necessary to sign in to Medium account) about scroll flags. Big thanks to Martin Ombura Jr!

    0 讨论(0)
提交回复
热议问题