I am trying to hide the toolbar when scrolling through a recyclerview. If i am wrapping the recyclerview with a nestedscrollview, scrolling happens but my performance is killed because it doesn't recycle my views. Do i have to use a nestedscrollingview or is there any other way to fix this?
Current layout:
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/homecoordinator"
xmlns:android="http://schemas.android.com/apk/res/android">
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/home_appbarlayout"
app:liftOnScroll="true"
android:background="@android:color/transparent"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/home_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_scrollFlags="scroll|enterAlways|snap"
app:title="@string/app_name"
app:menu="@menu/main_menu"
android:theme="@style/Toolbar"
/>
</com.google.android.material.appbar.AppBarLayout>
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior"
android:layout_height="wrap_content">
<androidx.recyclerview.widget.RecyclerView
android:layout_width="match_parent"
android:id="@+id/recycler_view_home"
android:nestedScrollingEnabled="false"
android:orientation="vertical"
android:layout_height="match_parent"
android:scrollbars="vertical"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:clipToPadding="false"
android:paddingBottom="200dp"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
/>
</androidx.core.widget.NestedScrollView>