I have an activity in which I use a RecyclerView, I am trying to make the Android bar collapse when I scroll over the RecyclerView, I have tried using NestedScrollView, but having many elements in the RecyclerView slowed down the activity.
<android.support.design.widget.AppBarLayout
android:id="@+id/app_bar_layout"
android:fitsSystemWindows="true"
android:layout_width="match_parent"
android:layout_height="250dp"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapsing_toolbar"
app:contentScrim="@color/semi_transparent"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:contentDescription="@string/background"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:fitsSystemWindows="true"
android:background="?attr/nav_background_drawable"
android:id="@+id/background"
app:layout_collapseMode="parallax"/>
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin"/>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v7.widget.RecyclerView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".myactivity"
android:id="@+id/recycler"/>
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="50dp"
android:layout_marginEnd="@dimen/fab_margin"
android:layout_marginRight="@dimen/fab_margin"
android:src="@drawable/ic_crono"
app:layout_anchor="@id/app_bar_layout"
app:layout_anchorGravity="bottom|right|end"/>
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab_charts"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="50dp"
android:layout_marginStart="@dimen/fab_margin"
android:layout_marginLeft="@dimen/fab_margin"
android:src="@drawable/ic_chart"
app:layout_anchor="@id/app_bar_layout"
app:layout_anchorGravity="bottom|left|start"/>