11

Per the new Android Material Design checklist:

http://android-developers.blogspot.com/2014/10/material-design-on-android-checklist.html

Where appropriate, upon scrolling down, the app bar can scroll off the screen, leaving more vertical space for content. Upon scrolling back up, the app bar should be shown again.

I realize there are lots of questions/answers to implement this behavior for the ICS-style app bar, but I'm curious if the new Toolbar widget or Lollipop/AppCompat 21 have introduced a more standard way of achieving this effect.

Eric Farraro
  • 865
  • 2
  • 7
  • 14
  • I have not seen anything in the documentation that suggests there is a built in method to hide the toolbar but since all it is, is a regular view just apply an animation to the toolbar when scrolling in either direction – tyczj Oct 28 '14 at 19:05

2 Answers2

6

Per Roman Nurik on Google+ (essentially what @tyczj mentioned)

https://plus.google.com/u/0/+RomanNurik/posts/3G8zYvN5oRC

It's not built in but relatively simple to implement. Just observe scrolling and animate the Y translation. Could also use the "quick return" sample +Nick Butcher​ and I published a few years ago

I believe that example referenced is: https://code.google.com/p/romannurik-code/source/browse/misc/scrolltricks

UPDATE: I also just discovered a great library that does this, along with some other great tricks https://github.com/ksoichiro/Android-ObservableScrollView

Eric Farraro
  • 865
  • 2
  • 7
  • 14
  • If using Toolbar, should it be on top of the content or next to it? – DariusL Dec 05 '14 at 17:29
  • @Eric your implementationis really nice. But i have recycleView in my fragment. So i am getting confuse for how to implement the ObservableScrolView with that. Can you please update your answer or give more details for how to implement it. – Shreyash Mahajan Mar 10 '15 at 09:59
  • @iDroidExplorer I haven't tried it myself yet, but when I looked into this, I did find a github with a library you might find useful -- it looks like it should have support for `RecyclerView` https://github.com/ksoichiro/Android-ObservableScrollView – Eric Farraro Mar 11 '15 at 21:39
  • @Eric thanks for reply but i have Recycler view with in that fragment. Now how to use ObservableScrollView with RecyclerView? Can you please give me any example you have? – Shreyash Mahajan Mar 12 '15 at 04:41
0

Ref: https://material.io/develop/android/components/app-bars-bottom

hiding app bar on scroll:

<com.google.android.material.bottomappbar.BottomAppBar
    android:id="@+id/bottomAppBar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="bottom"

    app:hideOnScroll="true"

    app:navigationIcon="@drawable/ic_menu_color_control_normal_24dp"
    app:navigationContentDescription="Navigation icon"
    android:fitsSystemWindows="true"
    />

Kotlin: programmatically

  bottomAppBar.hideOnScroll = true
Bolt UIX
  • 5,988
  • 6
  • 31
  • 58