Search code examples
androidandroid-recyclerviewandroid-toolbarandroid-coordinatorlayout

Toolbar leaving space when I tried to hide on RecyclerView scroll


I am trying to hide my toolbar on the scroll of recyclerView. And it hides on the scroll but the problem is that it leaves blank space after hiding.

And I follow the links below -

1 - TutLinks 1

2 - TutLinks 2


Solution

  • I have found the problem and fixed it. Actually, the problem is in include tag.

    In above code, I had used include tag and include tag can't perform the functionality of the toolbar. Means

    app:layout_scrollFlags="scroll|enterAlways"

    does not work in include tag.

    If I use the toolbar directly in the XML file with scrollFlags then everything works fine.

    Or in toolbar.xml add the layout_scrollFlags

    toolbar.xml

    <android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="?attr/colorPrimary"
        app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
        app:titleTextColor="#FFFFFF"
        app:layout_scrollFlags="scroll|enterAlways"   
        />
    

    After changing it, I have not needed to hide and show the toolbar manually.

    and Everything is working fine.