android - hide toolbar when scrolling recyclerview -


i new in material design,i unable hide toolbar when scrolling list.for more information sharing code given below:

1.common layout app

<?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"     android:id="@+id/drawer_layout"     android:layout_width="match_parent"     android:layout_height="match_parent"     android:fitssystemwindows="true">      <android.support.design.widget.coordinatorlayout         android:layout_width="match_parent"         android:layout_height="match_parent"         android:background="@android:color/background_light">          <relativelayout             android:id="@+id/main_container"             android:layout_width="match_parent"             android:layout_height="match_parent">              <linearlayout                 android:layout_width="match_parent"                 android:layout_height="match_parent"                 android:orientation="vertical">                 <!--  <include layout="@layout/custom_toolbar" />-->                 <relativelayout                     android:id="@+id/toolbarcontainer"                     android:layout_width="match_parent"                     android:layout_height="wrap_content">                      <android.support.design.widget.appbarlayout                         android:id="@+id/appbar"                         android:layout_width="match_parent"                         android:layout_height="wrap_content"                         android:fitssystemwindows="true"                         android:theme="@style/themeoverlay.appcompat.dark.actionbar">                           <android.support.v7.widget.toolbar                             android:id="@+id/customtoolbar"                             android:layout_width="match_parent"                             android:layout_height="wrap_content"                             android:background="@color/colorprimary"                             android:minheight="?attr/actionbarsize"                             android:textcolorprimary="@color/textcolorprimary"                             app:colorbuttonnormal="@android:color/white"                             app:colorcontrolhighlight="?attr/colorprimarydark"                             app:colorcontrolnormal="?android:attr/textcolorprimary"                             app:layout_scrollflags="scroll|enteralways"                             app:popuptheme="@style/themeoverlay.appcompat.light"                             app:theme="@style/themeoverlay.appcompat.dark.actionbar">                              <textview                                 android:id="@+id/actionbar_title"                                 android:layout_width="wrap_content"                                 android:layout_height="wrap_content"                                 android:gravity="center_horizontal"                                 android:textcolor="@color/colorprimarydark"                                 android:textsize="@dimen/action_bar_title_text_size"                                 android:textstyle="bold" />                              <imageview                                 android:id="@+id/toolbar_logo"                                 android:layout_width="wrap_content"                                 android:layout_height="wrap_content"                                 android:layout_gravity="left"                                 android:src="@drawable/btn_check_on"                                 android:visibility="gone" />                         </android.support.v7.widget.toolbar>                     </android.support.design.widget.appbarlayout>                      <imageview                         android:id="@+id/drawericon"                         android:layout_width="wrap_content"                         android:layout_height="wrap_content"                         android:layout_centerhorizontal="true"                         android:src="@drawable/img_drawer_logo" />                  </relativelayout>                  <android.support.design.widget.tablayout                     android:id="@+id/tabs"                     android:layout_width="match_parent"                     android:layout_height="wrap_content"                     android:visibility="gone"                     app:tabgravity="fill"                     app:tabmaxwidth="0dp"                     app:tabmode="fixed"                     app:tabselectedtextcolor="@color/orange_100"                     app:tabtextcolor="@color/grey" />                  <android.support.v4.view.viewpager                     android:id="@+id/viewpager"                     android:layout_width="match_parent"                     android:layout_height="match_parent"                     android:visibility="gone"                     app:layout_behavior="@string/appbar_scrolling_view_behavior" />                   <include layout="@layout/horizontal_line" />                 <!-- main content view, view below consumes entire                    space available using match_parent in both dimensions. -->                 <framelayout                     android:id="@+id/content_frame"                     android:layout_width="match_parent"                     android:layout_height="match_parent"                     android:layout_margintop="@dimen/baseline"                     app:layout_behavior="@string/appbar_scrolling_view_behavior" />             </linearlayout>              <moebel.de.app.ui.view.materialsearchview                 android:id="@+id/search_view"                 style="@style/materialsearchviewstyle"                 android:layout_width="match_parent"                 android:layout_height="match_parent" />              <moebel.de.app.ui.view.shopfindersearchview                 android:id="@+id/shopfinder_search_view"                 style="@style/shopfindersearchviewstyle"                 android:layout_width="match_parent"                 android:layout_height="match_parent" />              <linearlayout                 android:id="@+id/layout_progressbar"                 android:layout_width="match_parent"                 android:layout_height="match_parent"                 android:layout_gravity="center"                 android:background="@color/transparentcolor"                 android:gravity="center"                 android:visibility="visible">                  <progressbar                     android:id="@+id/progressbar1"                     style="@android:style/widget.progressbar.large"                     android:layout_width="wrap_content"                     android:layout_height="wrap_content" />             </linearlayout>          </relativelayout>     </android.support.design.widget.coordinatorlayout>      <relativelayout         android:id="@+id/drawer_left"         android:layout_width="@dimen/navigation_drawer_width"         android:layout_height="match_parent"         android:layout_gravity="start"         android:background="@color/drawerlistbackground"         android:clickable="true">          <listview             android:id="@+id/navigation_list"             android:layout_width="match_parent"             android:layout_height="wrap_content"             android:layout_centervertical="true"             android:choicemode="singlechoice"             android:divider="@null"             android:listselector="@drawable/drawer_list_selector" />          <imageview             android:layout_width="wrap_content"             android:layout_height="wrap_content"             android:layout_centerhorizontal="true"             android:src="@drawable/img_drawer_logo" />      </relativelayout>  </android.support.v4.widget.drawerlayout> 

2.run time adding fragment having layout:

<?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android"     xmlns:tools="http://schemas.android.com/tools"     android:layout_width="match_parent"     android:layout_height="match_parent"     android:background="@android:color/white"     android:clickable="true"     android:orientation="vertical">      <linearlayout         android:id="@+id/filterlayout"         android:layout_width="match_parent"         android:layout_height="44dp"         android:baselinealigned="false"         android:orientation="horizontal"         android:padding="@dimen/baseline">          <linearlayout             android:id="@+id/categorylayout"             android:layout_width="match_parent"             android:layout_height="match_parent"             android:layout_marginend="2dp"             android:layout_marginright="2dp"             android:layout_weight="0.5"             android:background="@color/grey_100"             android:gravity="center"             android:orientation="horizontal">              <imageview                 android:id="@+id/dotimage"                 android:layout_width="wrap_content"                 android:layout_height="wrap_content"                 android:layout_marginright="2dp"                 android:drawablepadding="@dimen/baseline"                 android:src="@drawable/dot_image"                 android:visibility="gone" />              <textview                 android:id="@+id/categorytext"                 android:layout_width="wrap_content"                 android:layout_height="wrap_content"                 android:drawableend="@drawable/ic_filter_arrow"                 android:drawablepadding="@dimen/baseline"                 android:drawableright="@drawable/ic_filter_arrow"                 android:text="@string/fragment_products_button_category"                 android:textcolor="@color/grey_400"                 android:textsize="18sp" />         </linearlayout>          <linearlayout             android:id="@+id/filter"             android:layout_width="match_parent"             android:layout_height="match_parent"             android:layout_marginleft="2dp"             android:layout_marginstart="2dp"             android:layout_weight="0.5"             android:background="@color/grey_100"             android:gravity="center"             android:orientation="horizontal">              <imageview                 android:id="@+id/filterdotimage"                 android:layout_width="wrap_content"                 android:layout_height="wrap_content"                 android:layout_marginright="2dp"                 android:drawablepadding="@dimen/baseline"                 android:src="@drawable/dot_image"                 android:visibility="gone" />              <textview                 android:layout_width="wrap_content"                 android:layout_height="wrap_content"                 android:drawableend="@drawable/ic_filter_arrow"                 android:drawablepadding="@dimen/baseline"                 android:drawableright="@drawable/ic_filter_arrow"                 android:text="@string/fragment_products_button_filter"                 android:textcolor="@color/grey_400"                 android:textsize="18sp" />         </linearlayout>     </linearlayout>      <linearlayout         android:layout_width="match_parent"         android:layout_height="match_parent"         android:orientation="vertical">          <relativelayout             android:layout_width="match_parent"             android:layout_height="match_parent"             android:layout_weight="0.1">               <android.support.v7.widget.recyclerview                 android:id="@+id/product_grid_view"                 android:layout_width="match_parent"                 android:layout_height="match_parent"                 android:overscrollmode="never"                 android:scrollbars="vertical"                 tools:listitem="@layout/product_grid_item" />               <textview                 android:id="@+id/listempty"                 android:layout_width="wrap_content"                 android:layout_height="wrap_content"                 android:layout_centerinparent="true"                 android:text="du hast keine produkte auf deinem merkzettel"                 android:visibility="gone" />                 <linearlayout                 android:id="@+id/layout_progressbar"                 android:layout_width="match_parent"                 android:layout_height="match_parent"                 android:layout_gravity="center"                 android:background="@color/transparentcolor"                 android:gravity="center"                 android:visibility="visible">                  <progressbar                     android:id="@+id/progressbar1"                     style="@android:style/widget.progressbar.large"                     android:layout_width="wrap_content"                     android:layout_height="wrap_content" />             </linearlayout>               <view                 android:id="@+id/transparent_view"                 android:layout_width="match_parent"                 android:layout_height="match_parent"                 android:background="@color/transparentcolor"                 android:visibility="gone"                 />          </relativelayout>          <linearlayout             android:id="@+id/layout_bottomprogressbar"             android:layout_width="match_parent"             android:layout_height="match_parent"             android:layout_weight="0.9"             android:background="@color/progressbarbackground"             android:gravity="center"             android:visibility="gone">              <progressbar                 style="@android:style/widget.progressbar.small"                 android:layout_width="wrap_content"                 android:layout_height="wrap_content" />         </linearlayout>      </linearlayout>  </linearlayout> 

please me find out solution .i stuck in problem don't know wrong in code .

add this:

app:layout_behavior="@string/appbar_scrolling_view_behavior" 

to recyclerview tag , root tag of fragment.


Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -