android - Toolbar is not scrolling off even after providing "app:layout_scrollFlags" flag -


i trying implement toolbar , tablayout in when scroll recycleview should hide toolbar whatsapp application. referring google blog , michal z's blog. have view pager in main activity , showing list of data inside using recycleview.

frankly speaking blown away new google design library because 1 line of xml code can change complete ui , ui behavior. idealy functionality need add app:layout_scrollflags="scroll|enteralways" line in toolbar , works. me not working. have tested on api 19 , 21 devices.

by going through question question on stack overflow , various blog blog found 2 way achieve functionality 1. providing scroll listener recycleview , 2. putting scrollable content inside nestedscrollview. didnt work expected.

i think should work without writing code.

main activity.xml

<android.support.design.widget.coordinatorlayout     xmlns:android="http://schemas.android.com/apk/res/android"     xmlns:app="http://schemas.android.com/apk/res-auto"     android:layout_width="match_parent"     android:layout_height="match_parent">      <android.support.design.widget.appbarlayout         android:layout_width="match_parent"         android:layout_height="wrap_content"         android:theme="@style/themeoverlay.appcompat.dark.actionbar">          <android.support.v7.widget.toolbar             android:id="@+id/toolbar"             android:layout_width="match_parent"             android:background="@color/colorprimary"             android:layout_height="?attr/actionbarsize"             app:layout_scrollflags="scroll|enteralways"             app:popuptheme="@style/base.themeoverlay.appcompat.dark"/>          <android.support.design.widget.tablayout             android:id="@+id/sliding_tabs"             android:background="@color/colorprimarydark"             android:layout_width="match_parent"             android:layout_height="wrap_content" />      </android.support.design.widget.appbarlayout>      <android.support.v4.view.viewpager         android:id="@+id/viewpager"         android:layout_width="match_parent"         android:layout_height="match_parent"         app:layout_behavior="@string/appbar_scrolling_view_behavior"/>  </android.support.design.widget.coordinatorlayout> 

viewpagerfragment.xml

<android.support.v4.widget.swiperefreshlayout xmlns:android="http://schemas.android.com/apk/res/android"     android:id="@+id/swipe_refresh_layout"     android:layout_width="fill_parent"     android:layout_height="fill_parent"     android:background="@color/windowbackground">      <android.support.v7.widget.recyclerview         android:id="@+id/order_list"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:layout_alignparenttop="true"         android:layout_alignparentleft= "true"         android:layout_alignparentstart="true"         android:layout_above="@+id/txtstatus" />  </android.support.v4.widget.swiperefreshlayout> 

your layout seems correct.
check in build.gradle version of recyclerview 22.2.0 , buildtoolsversion 22.0.1. need because new features appeared in 22.2.0 version of support library mentioned here.


Comments