Reputation: 5582
I'm trying to (inspired by https://mzgreen.github.io/2015/02/28/How-to-hideshow-Toolbar-when-list-is-scrolling(part2)) hide a view I have on top of my RecycleView when I scroll up, and display it when scrolled down.
But It doesn't seem to work great. When I scroll up the TextView does disappear but it leave a blank space from the the top to the start of the list view. (in the case below I use .setTransalteX(dy) on the textView
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/test"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<android.support.v7.widget.RecyclerView
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
What kind of layout should I use to archive the same but instead of leaving a blank space when I scroll up, the list takes the space of the textview ?
(Example of app that does this is the result list of Booking.com)
(It doesn't re appear when scroll down, but thats fine.. its the fact that search filter scroll up when the list scroll up)
Upvotes: 0
Views: 1730
Reputation: 6251
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<android.support.v7.widget.RecyclerView
android:id="@+id/recycler_view"
android:paddingTop="44dp"
android:cliptoPadding="false"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<TextView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/test"
android:layout_width="fill_parent"
android:layout_height="44dp" />
</LinearLayout>
Upvotes: 2