Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/209.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 回收器视图滚动而不折叠工具栏_Android - Fatal编程技术网

Android 回收器视图滚动而不折叠工具栏

Android 回收器视图滚动而不折叠工具栏,android,Android,回收器视图滚动而不折叠工具栏。这是我的主要布局 <CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/coordinator" android:layout_width="match_parent" android

回收器视图滚动而不折叠工具栏。这是我的主要布局

<CoordinatorLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/coordinator"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <android.support.design.widget.AppBarLayout
        android:id="@+id/appbar"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:animateLayoutChanges="true"
       >

        <android.support.design.widget.CollapsingToolbarLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:id="@+id/collapp_bar"
            app:layout_scrollFlags="scroll|exitUntilCollapsed"
            >
            <View
                android:id="@+id/image"
                android:layout_width="fill_parent"
                android:layout_height="220dp"
                app:layout_collapseMode="parallax"
                android:background="@android:color/transparent"
                />
            <include layout="@layout/custom_toolbar" />
            <android.support.v4.widget.NestedScrollView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                app:layout_collapseMode="parallax"
                android:layout_gravity="bottom"
                android:id="@+id/nestedScrollView"
                android:layout_marginBottom="10dp"
                >
            <android.support.v7.widget.RecyclerView
                android:layout_width="match_parent"
                android:id="@+id/recyclerView"
                android:layout_height="wrap_content"
                android:orientation="horizontal" />
            </android.support.v4.widget.NestedScrollView>
        </android.support.design.widget.CollapsingToolbarLayout>

    </android.support.design.widget.AppBarLayout>
    <ViewPager
        android:id="@+id/viewpager"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="#f4f4f4"
        app:layout_behavior="@string/appbar_scrolling_view_behavior"
        />


 <android.support.design.widget.TabLayout
        android:id="@+id/tab_layout"
        android:layout_width="fill_parent"
        android:layout_height="50dp"
        app:tabMode="fixed"
        app:tabGravity="fill"
        app:tabTextColor="@color/gray"

        app:tabSelectedTextColor="@color/selected_text_color"
        app:tabIndicatorColor="@color/more_comment_color"
        android:background="@android:color/background_light"
        android:layout_gravity="bottom"

        />
    <ImageView
        android:id="@+id/imageView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom|center_horizontal"
        app:layout_anchor="@id/tab_layout"

        app:layout_anchorGravity="bottom|center"
        android:layout_marginTop="-20dp"
        />

</CoordinatorLayout>

这是我在View Pager中设置的布局

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/container"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@android:color/white">

     <android.support.v4.widget.SwipeRefreshLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/swipe"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
       >


        <android.support.v7.widget.RecyclerView
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/recyler_view"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@color/bg_listview" /></android.support.v4.widget.SwipeRefreshLayout>
    </RelativeLayout>


我的Recycler视图有时会滚动,即使没有折叠工具栏。另外,滚动也不顺畅。在recyClerView of view pager中,我有一个标题项,然后是项目列表。有时它会卡在顶部的标题处,需要将其向下拉。

对于每个具有滚动父级的recyClerView(如ScrollView或NestedScrollView)应禁用嵌套滚动,如下所示:

yourRecyclerView.setNestedScrollingEnabled(false);
对于平滑问题,AppBarLayout似乎有一个bug,并且有一些库可以修复它。我知道但从未使用过的是: