3

I'm trying to achieve this behaviour with a floating search view, where the NestedScrollView scrolls under the app bar layout.

Step 1

Step 2

Step 3

What I have at the moment is this, where the scrollview is below the appbarlayout:

What I have

Some code:

    <android.support.design.widget.AppBarLayout android:layout_width="match_parent"
                                                android:layout_height="@dimen/appbar_home"
                                                android:background="@null"
                                                app:elevation="0dp">


            <com.arlib.floatingsearchview.FloatingSearchView android:id="@+id/floating_search_view"
                                                             style="@style/SearchView"
                                                             android:layout_width="match_parent"
                                                             android:layout_height="match_parent"
                                                             app:layout_scrollFlags="scroll|enterAlways|snap"
                                                             app:floatingSearch_searchBarMarginLeft="@dimen/content_spacing"
                                                             app:floatingSearch_searchBarMarginRight="@dimen/content_spacing"
                                                             app:floatingSearch_searchBarMarginTop="32dp"
                                                             app:floatingSearch_close_search_on_keyboard_dismiss="true"
                                                             app:floatingSearch_leftActionMode="showSearch"
                                                             app:floatingSearch_menu="@menu/menu_home"
                                                             app:floatingSearch_searchHint="Search..."
                                                             app:floatingSearch_showSearchKey="false"
                                                             app:floatingSearch_suggestionsListAnimDuration="250"/>

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

    <android.support.v4.widget.NestedScrollView android:layout_width="match_parent"
                                                android:layout_height="match_parent"
                                                app:layout_behavior="@string/appbar_scrolling_view_behavior">

        <FrameLayout android:id="@+id/scroll"
                     android:layout_width="match_parent"
                     android:layout_height="match_parent">

            <ImageView android:layout_width="match_parent"
                       android:layout_height="wrap_content"
                       android:scaleType="fitXY"
                       android:src="@drawable/test"/>


        </FrameLayout>


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


</android.support.design.widget.CoordinatorLayout>
akshaydashrath
  • 1,025
  • 8
  • 18
  • move the margins from FloatingSearchView to AppBarLayout -- AppBarLayout should have this width and height settings (android:layout_width="match_parent" --- android:layout_height="wrap_content" ) and FloatingSearchView (android:layout_height="@dimen/appbar_home") – Tasos Oct 09 '16 at 13:11
  • @Tasos the thing is the content goes under the status bar, the appbarlayout size takes this into consideration so the hieght is status bar height + height of the the search view – akshaydashrath Oct 09 '16 at 13:23
  • i see so how about taking out the AppBarLayout or make it transparent eg (android:background="00000000") or try using a FrameLayout instead of AppBarLayout – Tasos Oct 09 '16 at 13:47
  • I need AppBarLayout to sync the scrolling of the nested scroll view with the search view – akshaydashrath Oct 09 '16 at 14:05
  • Instead of using a Nested Scrollview -- Try this design -- https://github.com/arimorty/floatingsearchview/blob/master/sample/src/main/res/layout/fragment_sliding_search_results_example_fragment.xml -- assuming you are using a recycler view to show all those images add a scroll listener and make the FloatingSearchView (VISIBLE) or (GONE) as you scroll UP or DOWN -- http://stackoverflow.com/questions/29024058/recyclerview-scrolled-up-down-listener – Tasos Oct 09 '16 at 14:51

0 Answers0