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> 

5
  • I think your problem is wrap_content for the toolbar content height. Commented Jan 3, 2016 at 11:22
  • Do you mean the "wrap_content" in the <RelativeLayout> that is the first child of <android.support.design.widget.CollapsingToolbarLayout? Could you suggest what it should be instead, if not wrap_content? Commented Jan 4, 2016 at 16:16
  • just try using 40dp or something :) Commented Jan 4, 2016 at 16:30
  • Did you find a solution? Commented Jan 31, 2017 at 10:24
  • Nopes, nothing worked. Finally I just created a gridview, where the first row was the header and mimiced the behavior of collapsing tool bar based on the % visibility of the first row. Unfortunately I can't find the code now. If I am able to, will post it for sure. Commented Apr 4, 2018 at 18:11

1 Answer 1

1

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

<android.support.v4.widget.NestedScrollView> 

wrapping the recyclerview should do it.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.