首页 > 解决方案 > 为什么recycleview不滚动折叠appbarlayout

问题描述

在我使用nestedSrollview 之前,appbarLayout 折叠得很好,但现在我使用recycleview 并且它不滚动

 <android.support.design.widget.CoordinatorLayout
 xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#bdbdbd"
android:fitsSystemWindows="false"
>
  <android.support.v7.widget.RecyclerView
    android:id="@+id/discount_list_recycle"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:nestedScrollingEnabled="true"
    android:padding="@dimen/item_offset"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"/>

<android.support.design.widget.AppBarLayout
    android:id="@+id/app_bar_layout"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:fitsSystemWindows="true"
    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_constraintTop_toTopOf="parent"
        android:background="@color/colorPrimary"
        app:layout_scrollFlags="scroll" >
           ....

    </android.support.v7.widget.Toolbar>

    <android.support.design.widget.CollapsingToolbarLayout
        android:id="@+id/collapsing_toolbar"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fitsSystemWindows="true"
        app:contentScrim="?attr/colorPrimary"
        app:layout_scrollFlags="scroll|exitUntilCollapsed">


        <android.support.constraint.ConstraintLayout
            android:id="@+id/slider_layout"
            android:layout_width="match_parent"
            android:layout_height="200dp" >

            <android.support.v4.view.ViewPager
                android:id="@+id/image_slider_view_pager"
                ....
          />

        </android.support.constraint.ConstraintLayout>

    </android.support.design.widget.CollapsingToolbarLayout>


</android.support.design.widget.AppBarLayout>

当recycleview滚动并且工具栏没有进入时,我想折叠工具栏和viewpager总是对不起我的英语

标签: androidandroid-recyclerviewandroid-collapsingtoolbarlayoutandroid-appbarlayout

解决方案


推荐阅读