Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Toolbar disappear during scrolling with Coordinatorlayout

a strange thing happened when I try to implement the toolbar with the Coordinatorlayout.

  1. everything seems ok when I scroll down and scroll up the toolbar show correctly

enter image description here

  1. however after I scroll down to a certain level the screen became

enter image description here

The XML is below, any idea of it, 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>

like image 705
Kenny Avatar asked Jun 15 '15 03:06

Kenny


Video Answer


1 Answers

Place a blank view below your Toolbar before the AppBarLayout closing statement. It 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>
like image 84
McGuile Avatar answered Dec 15 '22 00:12

McGuile