CoordinatorLayout 在滚动端折叠或展开 AppBar

CoordinatorLayout Collapse or Expand AppBar on scroll end

有没有办法根据滚动结束时可见的可折叠视图的百分比向上或向下移动 AppBar。在 CheeseSquare 应用中,工具栏可能会在滚动结束时卡在中间。

谢谢

这就是 SCROLL_FLAG_SNAP 的确切用例:

Upon a scroll ending, if the view is only partially visible then it will be snapped and scrolled to it's closest edge. For example, if the view only has it's bottom 25% displayed, it will be scrolled off screen completely. Conversely, if it's bottom 75% is visible then it will be scrolled fully into view.

已添加到 Android 支持库的 version 23.1 中。

您也可以通过 XML:

使用它
<android.support.v7.widget.Toolbar
    app:layout_scrollFlags="scroll|enterAlways|snap" />