Android 当应用程序栏捕捉时,如何使RecyclerView保持静止?
AppBarLayout捕捉时,CoordinatorLayout向上滚动RecyclerView。相反,我希望AppBarLayout在不更改RecyclerView的滚动位置的情况下重新捕捉到位。Google Play Store应用程序具有我试图实现的行为 如何在AppBarLayout捕捉时保持RecyclerView静止 以下是我的布局:Android 当应用程序栏捕捉时,如何使RecyclerView保持静止?,android,material-design,android-coordinatorlayout,android-appbarlayout,Android,Material Design,Android Coordinatorlayout,Android Appbarlayout,AppBarLayout捕捉时,CoordinatorLayout向上滚动RecyclerView。相反,我希望AppBarLayout在不更改RecyclerView的滚动位置的情况下重新捕捉到位。Google Play Store应用程序具有我试图实现的行为 如何在AppBarLayout捕捉时保持RecyclerView静止 以下是我的布局: <?xml version="1.0" encoding="utf-8"?> <android.supp
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
android:id="@+id/appbar"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_scrollFlags="scroll|enterAlways|snap" />
</android.support.design.widget.AppBarLayout>
<android.support.v7.widget.RecyclerView
android:id="@+id/rvToDoList"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
</android.support.design.widget.CoordinatorLayout>
使用
在build.grade
中添加:
compile 'it.michelelacorte.retractabletoolbar:library:1.0.0'
而不是在您的活动中
(将回收视图和工具栏与您的一起更改):
结果:
像这样吗?是的,就这样。这方面的来源是否可用?请查看以下内容:
RetractableToolbarUtil.ShowHideToolbarOnScrollingListener showHideToolbarListener;
recyclerView.addOnScrollListener(showHideToolbarListener = new RetractableToolbarUtil.ShowHideToolbarOnScrollingListener(toolbar));
if (savedInstanceState != null) {
showHideToolbarListener.onRestoreInstanceState((RetractableToolbarUtil.ShowHideToolbarOnScrollingListener.State) savedInstanceState
.getParcelable(RetractableToolbarUtil.ShowHideToolbarOnScrollingListener.SHOW_HIDE_TOOLBAR_LISTENER_STATE));
}