android - Hide Toolbar with CoordinatorLayout, but RecyclerView on a fragment -


i have activity 2 tabs. each tab contains fragment swiperefreshlayout , recyclerview inside them.

in activity, have coordinatorlayout appbarlayout (with toolbar , tablayout) , viewpager fragments.

screenshot

now, want achieve is: when user scrolls in fragments, toolbar, , not tabs, hides, in play store.

in examples have read on internet, layout simple: have recyclerview , toolbar inside coordinatorlayout on same xml.

then, write:

<android.support.v7.widget.recyclerview     android:id="@+id/rvtodolist"     android:layout_width="match_parent"     android:layout_height="match_parent"     app:layout_behavior="@string/appbar_scrolling_view_behavior"> 

and

<android.support.design.widget.appbarlayout     android:layout_width="match_parent"     android:layout_height="wrap_content"     android:fitssystemwindows="true">         <android.support.v7.widget.toolbar             android:id="@+id/toolbar"             android:layout_width="match_parent"             android:layout_height="?attr/actionbarsize"             app:layout_scrollflags="scroll|enteralways"/> </android.support.design.widget.appbarlayout> 

so, can't figure out how it.

my xml's following:

the activity layout is:

<android.support.v4.widget.drawerlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/activity_main_drawer_layout" android:layout_width="match_parent" android:layout_height="match_parent" android:fitssystemwindows="true">  <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:fitssystemwindows="true">              <android.support.v7.widget.toolbar xmlns:android="http://schemas.android.com/apk/res/android"                 android:id="@+id/activity_main_toolbar"                 android:layout_width="match_parent"                 android:layout_height="?attr/actionbarsize"                 android:background="@color/color_primary"                 app:layout_scrollflags="scroll|enteralways"/>              <android.support.design.widget.tablayout                 android:id="@+id/activity_main_tab_layout"                 android:layout_width="match_parent"                 android:layout_height="wrap_content"                 app:tabindicatorcolor="@color/color_text_primary"                 app:tabmode="fixed" />          </android.support.design.widget.appbarlayout>          <android.support.v4.view.viewpager             android:id="@+id/activity_main_tabs_pager"             android:layout_width="match_parent"             android:layout_height="match_parent"       app:layout_behavior="@string/appbar_scrolling_view_behavior"/>   </android.support.design.widget.coordinatorlayout>  <listview     android:id="@+id/activity_main_nav_drawer_list"     android:layout_width="match_parent"     android:layout_height="match_parent"     android:layout_gravity="start"     android:background="@color/color_primary"     android:choicemode="singlechoice"     android:divider="@android:color/transparent"     android:dividerheight="5dp"     android:overscrollmode="never"     android:smoothscrollbar="true" /> </android.support.v4.widget.drawerlayout> 

and fragments are:

<android.support.v4.widget.swiperefreshlayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/fragment_coupons_swipe_refresh_view" android:layout_width="match_parent" android:layout_height="match_parent">  <com.github.yasevich.endlessrecyclerview.endlessrecyclerview     android:id="@+id/fragment_coupons_recycler_view"     android:layout_width="match_parent"     android:layout_height="match_parent"     android:scrollbars="vertical" /> </android.support.v4.widget.swiperefreshlayout> 

thanks in advance.

man, faced same problem. problem not in code. bet using old versions of build tools , libraries. update them latest:

  • buildtoolsversion "22.0.1"
  • com.android.support:appcompat-v7:22.1.1
  • com.android.support:recyclerview-v7:22.2.0

in case worked charm! luck!


Comments