android - Collapsing toolbar and recyclerview does not collapse when scrolling -
i implemented collapsing toolbar in 1 of activities , upon scrolling toolbar not collapse:
<?xml version="1.0" encoding="utf-8"?> <android.support.v4.widget.swiperefreshlayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/swipecontainer" android:layout_width="match_parent" android:layout_height="match_parent"> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:background="@color/white" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <android.support.design.widget.appbarlayout android:id="@+id/app_bar" android:fitssystemwindows="true" android:layout_height="@dimen/app_bar_height" android:layout_width="match_parent" android:theme="@style/apptheme.appbaroverlay"> <android.support.design.widget.collapsingtoolbarlayout android:id="@+id/toolbar_layout" android:fitssystemwindows="true" android:layout_width="match_parent" android:layout_height="match_parent" app:layout_scrollflags="scroll|exituntilcollapsed" app:contentscrim="?attr/colorprimary"> <android.support.v7.widget.toolbar android:id="@+id/toolbar" android:layout_height="?attr/actionbarsize" android:layout_width="match_parent" app:layout_collapsemode="pin" app:popuptheme="@style/apptheme.popupoverlay" /> </android.support.design.widget.collapsingtoolbarlayout> </android.support.design.widget.appbarlayout> <android.support.v7.widget.recyclerview android:id="@+id/my_recycler_view" android:layout_width="match_parent" android:layout_height="match_parent" app:layout_behavior="@string/appbar_scrolling_view_behavior" android:scrollbars="none" /> </linearlayout> </android.support.v4.widget.swiperefreshlayout>
i added required libraries gradle. toolbar stays @ same spot when scrolling down. idea why happening?
the appbarlayout needs coordinatorlayout.
this view depends heavily on being used direct child within coordinatorlayout. if use appbarlayout within different viewgroup, of it's functionality not work.
quoted developer.android.com/reference/android/support/design/widget/appbarlayout.html
also have @ these tutorials : http://antonioleiva.com/collapsing-toolbar-layout/
Comments
Post a Comment