I try to hide the HEADER layout when I scroll on a recyclerview. In order to hide the layout I use an animation in the "onScrolled" event :
-Show :
layout.animate().translationY(-layout.getHeight()).setInterpolator(new AccelerateInterpolator(2));
-Hide :
layout.animate().translationY(0).setInterpolator(new DecelerateInterpolator(2));
It's working in a way but I've still got a blank space where the HEADER was.
liste_view_layout :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
android:orientation="vertical"
android:weightSum="1">
<!-- HEADER -->
<include layout="@layout/header_list_view" />
<FrameLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<include layout="@layout/common_recyclerview_layout"/>
</FrameLayout>
</LinearLayout>
header_list_view :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/header_list_view_layout_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:animateLayoutChanges="true"
>
<TopBarHeaderView
android:id="@+id/header_list_view_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<FrameLayout
android:id="@+id/subcategory_header_section"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<include layout="@layout/header_section"/>
</FrameLayout>
</TopBarHeaderView>
</LinearLayout>
