renaudcerrato/FloatingSearchView

Hide FSV when scrolling

Open

#15 opened on May 23, 2016

View on GitHub
 (10 comments) (0 reactions) (0 assignees)Java (1,337 stars) (169 forks)batch import
help wanted

Description

Hello,

is it possible to hide FSV when scrolling down the .

I would like to achieve similar effect as Google Play with the searchview on its main page. But as this widget is not like a toolbar and it should be above the content I cannot place it inside AppBarLayout. If I do so, the AppBarLayout takes height of entire display.

My layout looks like this:

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    tools:openDrawer="start" >

    <android.support.design.widget.CoordinatorLayout
        android:id="@+id/coordinator"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fitsSystemWindows="true"
        >

        <ScrollView
            android:layout_width="match_parent"
            android:layout_height="match_parent">

            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" android:orientation="vertical">

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="@string/lorem_ipsum"
                    />
            </LinearLayout>
        </ScrollView>

            <com.mypopsy.widget.FloatingSearchView
                android:id="@+id/fsv_search"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:paddingTop="@dimen/search_view_inset_top"
                android:paddingRight="@dimen/search_view_inset"
                android:paddingLeft="@dimen/search_view_inset"
                app:logo="@drawable/logo"
                android:theme="@style/CustomFloatingSearchViewTheme"
                app:fsv_contentBackgroundColor="@color/searchbox_background"
                app:layout_scrollFlags="scroll|enterAlways"
                />

    </android.support.design.widget.CoordinatorLayout>

    <android.support.design.widget.NavigationView
        android:id="@+id/nav_view"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:fitsSystemWindows="true"
        app:headerLayout="@layout/nav_header_main"
        app:menu="@menu/activity_main_drawer" />

</android.support.v4.widget.DrawerLayout>

Thank you.

Contributor guide