4

I have a very simple RecyclerView inside a Collapsing Toolbar layout. I have tried every possible flag / researched everywhere I could but cannot get my collapsing toolbar to collapse. The Recycler scrolls freely, but the collapsingtoolbar just stays there, unless, I scroll the collapsingtoolbar itself. What am I doing wrong, can anyone please help? Any help will be much much appreciated..

XML as follows (Just to keep the code clean, have removed the section within the Relative Layout of the Collapsing toolbar):

<!-- The CoordinatorLayout is used to coordinate (rly) scroll events between different views -->
<android.support.design.widget.CoordinatorLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent">

<!-- The AppBar (everything above the scrolling content) -->
<android.support.design.widget.AppBarLayout
    android:layout_height="wrap_content"
    android:layout_width="match_parent"
    android:id="@+id/activity_main__app_bar"
    android:fitsSystemWindows="true"
    app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">



<android.support.design.widget.CollapsingToolbarLayout
    android:id="@+id/activity_main__collapsing_toolbar"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:minHeight="0dp"
    android:fitsSystemWindows="true"
    app:contentScrim="@color/dark_for_menu"
    app:layout_scrollFlags="scroll|exitUntilCollapsed"
    app:layout_collapseMode="parallax" >

    <RelativeLayout
        android:id="@+id/coverSwappsterMode"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content">

    </RelativeLayout>


<android.support.v7.widget.Toolbar
    android:id="@+id/toolbar"
    android:layout_width="match_parent"
    android:layout_height="?attr/actionBarSize"
    app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
    app:layout_scrollFlags="scroll|exitUntilCollapsed"
    app:layout_collapseMode="pin" >


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

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

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




            <android.support.v7.widget.RecyclerView
                android:id="@+id/listSwappsterMode"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:minHeight="@dimen/dp_500"
                android:background="@color/dark_background"
                app:layout_behavior="@string/appbar_scrolling_view_behavior"
                >
            </android.support.v7.widget.RecyclerView>





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

Vaibhav Gupta
  • 59
  • 1
  • 5

1 Answers1

1

you need to put your page layout inside a "nested scroll view"

<android.support.v4.widget.NestedScrollView>

wrapping the recyclerview should do it.