Push out/pull in ActionBar when ListView is scrolled


The latest Google Newsstand App features an ActionBar and ViewPager tab bar which slowly eases out the top of the screen when the list below it is scrolled down. <strong>Importantly, it eases out at the same speed the list is scrolled</strong>. When the list is scrolled upwards the ActionBar eases back onto the screen, <strong>again at the same speed the list is scrolled</strong>.

<em>I am not referring to the ActionBar hide() and show() methods, instead I want to know how to hide and show the ActionBar at the same rate the list below it is scrolled.</em>

How is this achieved? All attempts at finding a documented solution have proven unsuccessful so any help would be appreciated.


<h2>Short Answer</h2>

Create a Fragment subclass that serves as an ActionBar replacement. Use an OnScrollListener to update the fragment's view's translationY after scroll events.

<h2>Long Answer</h2>

After digging around the ActionBar source code, it seems that there is no public method for accessing the ActionBar container view. But where there's a will, <a href="https://stackoverflow.com/questions/20023483/how-to-get-actionbar-view" rel="nofollow">there's a way</a>.

You can grab a reference to the Action Bar's view using the following:

int resId = getResources().getIdentifier("action_bar_container", "id", "android"); View actionBarContainer = findViewById(resId);

<strong>Disclaimer</strong>: action_bar_container is a private ID, so it's subject to Google's whims. Use at your own risk.

Once you have the Action Bar's view, you can animate it however you'd like.

I hacked together <a href="https://github.com/bamatson/PushPullActionBarDemo" rel="nofollow">a semi-functional example</a> if you're interested.

Hope this helps!


  • Converting string to date in Crystal Reports
  • Converting string to date in Crystal Reports
  • What is “verifiable managed assembly”
  • Merging a changing collection of observables
  • Python function optional arguments - possible to add as condition?
  • Makefile : how to increment a variable when you call it? (var++ in bash)
  • Display a numeric keypad on activity without an input area
  • How to use an EventToCommand with an editable Combobox to bind TextBoxBase.TextChanged with a comman
  • SQL Server performance issue with parameters
  • Best way to handle offline and online development with Git
  • Jest - Cannot find module 'setupDevtools' from 'setup.js'
  • Hudson - different build targets for different triggers
  • Chef recipe for RoR Heroku
  • Merge several columns into one with specific conditions in R
  • Parse an XML fragment stored in a string into nodes in XSLT with SAXON for Java
  • How to prompt user that edits have been made upon changing pages or sorting in Kendo Grid
  • How to get file download speed (transfer rate) with php?
  • Return to second to last URL in MVC (return View with previous filter conditions applied)?
  • Counting Treaps
  • Should a web service response include empty values?
  • Making Google Visualization - Annotation Chart to work in GWT
  • .NET video play library which allows to change the playback rate?
  • Check all values in string[] for length?
  • UWP/C# - Issue with AQS and USB Devices
  • How to make JSON.NET deserialize to Microsoft Date Time?
  • Alternative to overridePendingTransition() - Android
  • How to match http request and response using Jersey ContainerRequestFilter and ContainerResponseFilt
  • one Local Olampyad Questions on Informatic in 2011
  • Azure Cloud Service Web Role web pages do not load
  • swift auto completion not working in Xcode6-Beta
  • Excel - Autoshape get it's name from cell (value)
  • Finding past revisions of files in StarTeam w/ .NET SDK / C#
  • Check if a string to interpolate provides expected placeholders
  • Do create extension work in single-user mode in postgres?
  • RestKit - RKRequestDelegate does not exist
  • Traverse Array and Display in markup
  • Cannot Parse HTML Data Using Android / JSOUP
  • C# - Getting references of reference
  • Why joiner is not used after Sequence generator or Update statergy
  • Net Present Value in Excel for Grouped Recurring CF