0

i Created a Tool bar without using Collapsing Toolbar. I need to hide the toolbar on scrolling up the Recycler view.i followed link for scrolling/hiding toolbar

http://android-developers.blogspot.com/2015/05/android-design-support-library.html

Here is my xml

<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
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.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:layout_scrollFlags="scroll|exitUntilCollapsed" />
</android.support.design.widget.AppBarLayout>

<android.support.v7.widget.RecyclerView
    android:id="@+id/recycler_view"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:scrollbars="vertical"
    app:layout_behavior="@string/appbar_scrolling_view_behavior" /></android.support.design.widget.CoordinatorLayout>

Here is my output enter image description here I am Not sure where its going wrong. I did every thing correctly . But on scrolling the recycler view the Toolbar stays at the same position. Its not hiding.

Your help is much appreciated.

2 Answers 2

2

There are known issues with using using wrap_content for your Toolbar. Instead, use a fixed height:

<android.support.v7.widget.Toolbar
    android:id="@+id/toolbar"
    android:layout_width="match_parent"
    android:layout_height="?attr/actionBarSize"
    app:layout_scrollFlags="scroll|enterAlways" />

You'll note I use scroll|enterAlways - exitUntilCollapsed only makes sense when you are using a CollapsingToolbarLayout (or any layout that has a different layout_height and minHeight).

1
  • app:layout_scrollFlags="scroll|enterAlways" is worked for me. The Toolbar got hidden. Commented Aug 22, 2015 at 15:17
0

Also make sure build.gradle has at least buildToolsVersion "22.0.1" and

compile 'com.android.support:design:22.2.0'
compile 'com.android.support:recyclerview-v7:22.2.0'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.