Android navigation bar scroll flag app: layout_scrollFlags detailed explanation

1.app:layout_scrollFlags attribute introduction

When introducing the usage of AppBarLayout and CollapsingToolbarLayout earlier, the app:layout_scrollFlags property was used. In fact, this scrolling flag attribute comes from AppBarLayout, which is used to define the specific scrolling behavior of lower-level controls, such as whether to roll first or back, whether to roll half or all, whether to roll automatically or manually, etc.

2. Scenarios of different scrolling behaviors

  • The scrolling of AppBarLayout depends on the scrolling of the page body. Corresponding to the page body, AppBarLayout can be called the page header. Since a page is divided into two parts, the head and the main body, there is a problem of who rolls first and who rolls back.
  • The height inside AppBarLayout may also change, for example, it nests CollapsingToolbarLayout. Since the height of AppBarLayout changes, it must be distinguished whether to roll half or roll all.
  • AppBarLayout has been pulled for a while and has not been pulled yet. At this time, once you release your finger, it usually stops in place. But the brakes halfway are unsightly, so you have to judge whether to continue to stop, or continue to shrink upward, or continue to expand downward.

3. Introduction to five scroll signs

  • scroll: This sign indicates that the head and the main body scroll together.
  • enterAlways: This sign indicates that the head and the main body roll together first, and the main body continues to roll up or down after the head rolls into place.
  • exitUntilCollapsed: This sign ensures that at least the minimized toolbar can be seen on the page, and the toolbar will not be completely hidden. The specific scrolling behavior is divided into two types, scrolling up and scrolling down. Scrolling up means that the head first shrinks and rolls to the minimum folding height; then the head is fixed, and the main body continues to scroll up; and scrolling down means that The head is fixed, the main body rolls down first, and rolls until the main body is fully pulled out; then the head unfolds down.
  • enterAlwaysCollapsed: This flag is generally used together with enterAlways. The difference between enterAlways and enterAlways is that there is a folding operation, while the single enterAlways is not folded. The specific scrolling behavior is also divided into two types: scrolling up and scrolling down. Rolling up means that the head first shrinks upwards and rolls to the minimum folding height; then the head and the main body roll together, and after the head rolls into place, the main body Keep going up. And scrolling down means that the head and the main body roll together first, until the minimum height of the head is folded; then the main body rolls down, and the head continues to unfold after being rolled into place.
  • snap: When the user's finger is released, the system judges on its own whether to scroll all up to the top or expand all down.

The difference between 4.5 scroll signs

Scroll flag value Description
scroll Simple and plain scrolling, nothing tricky
enterAlways The difference between this logo and scroll is that it allows the head to cover the main body, while scroll will not cover
exitUntilCollapsed After setting this flag, you will always see a toolbar on the page
enterAlwaysCollapsed The difference between this flag and enterAlways is that it supports the folding effect set by layout_collapseMode
snap After setting this flag, whenever the user releases the gesture, the system will automatically determine whether to shrink upward or expand downward

 

Guess you like

Origin blog.csdn.net/weixin_38322371/article/details/114987302