Android toolbar disappears while scrolling with Coordinatorlayout

A strange thing happened when I try to implement a toolbar using Coordinatorlayout .

  • everything looks fine when i scroll down and scroll toolbar image correctly

enter image description here

  1. however, after scrolling down to a certain level, the screen became

enter image description here

XML below, any idea, thanks?

 <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.v7.widget.RecyclerView android:id="@+id/list" android:layout_width="match_parent" android:layout_height="match_parent" app:layout_behavior="@string/appbar_scrolling_view_behavior" /> <android.support.design.widget.AppBarLayout android:id="@+id/appbar" android:layout_width="match_parent" android:layout_height="wrap_content"> <android.support.v7.widget.Toolbar android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" android:background="?attr/colorPrimary" android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" app:layout_scrollFlags="scroll|enterAlways" /> </android.support.design.widget.AppBarLayout> 

+7
android toolbar
source share
1 answer

Place a blank view below the Toolbar in front of the AppBarLayout close AppBarLayout . This worked for me when I had this problem.

 <android.support.design.widget.AppBarLayout android:id="@+id/appbar" android:layout_width="match_parent" android:layout_height="wrap_content"> <android.support.v7.widget.Toolbar android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" android:background="?attr/colorPrimary" android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" app:layout_scrollFlags="scroll|enterAlways" /> <View android:id="@+id/appbar_bottom" android:layout_width="match_parent" android:layout_height="1dp" android:background="@android:color/transparent" android:visibility="invisible" /> </android.support.design.widget.AppBarLayout> 
+12
source share

All Articles