CollapsingToolbarLayout expand only when at the top

后端 未结 5 950
耶瑟儿~
耶瑟儿~ 2021-02-05 17:58

I have some problems with AppBarLayout and CollapsingToolbarLayout. This is what currently happens:

https://www.youtube.com/watch?v=z4yD8rmjSjU

The downwards scr

5条回答
  •  天命终不由人
    2021-02-05 18:23

    There are lots of effects on the scrolling behavior that can be achieved by setting different layout_scrollFlags. In your case, I think the flag you want is enterAlwaysCollapsed. Add the flag along with enterAlways instead of replacing all the flags.

    scroll will make the toolbar scroll like the rest of the content, enterAlways will make the toolbar AND the rest of the CollapsingToolbarLayout to pop back immediately after scroll up, whereas enterAlwaysCollapsed only expands the CollapsingToolbarLayout after the page is scrolled all the way to the top.

    Here's the effect that enterAlwaysCollapsed achieves.

提交回复
热议问题