Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/33.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 当应用程序栏捕捉时,如何使RecyclerView保持静止?_Android_Material Design_Android Coordinatorlayout_Android Appbarlayout - Fatal编程技术网

Android 当应用程序栏捕捉时,如何使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

AppBarLayout捕捉时,CoordinatorLayout向上滚动RecyclerView。相反,我希望AppBarLayout在不更改RecyclerView的滚动位置的情况下重新捕捉到位。Google Play Store应用程序具有我试图实现的行为

如何在AppBarLayout捕捉时保持RecyclerView静止

以下是我的布局:

        <?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));
}