ActionBar or ActionBarSherlock - Smoothly Hide / Show the ActionBar

Josh picture Josh · Jun 29, 2012 · Viewed 8.8k times · Source

I'm using ActionBarSherlock, and attempting to hide / show the ActionBar for fullscreen images, using:

getSupportActionBar.hide();

and

getSupportActionBar.show();

But it is really jumpy and awkward. Is there a way to make it smoother, or to apply a translation / opacity animation?

Upon further inspection of ABS source, and through observing its behavior, it seems to have at least a minimal amount of animation defined. The same cannot be said for the standard ActionBar.

Just for completeness, here is the relevant code I'm call from an ImageView.click:

if( shouldRender )
{
  . . .

  getSupportActionBar().hide();

  getWindow().addFlags( WindowManager.LayoutParams.FLAG_FULLSCREEN );
}
else
{
  . . .

  getSupportActionBar().show();

  getWindow().clearFlags( WindowManager.LayoutParams.FLAG_FULLSCREEN );
}

It's worth noting that the flags setting / clearing also causes a jump, but a much less noticeable one, so I was going to tackle it later, if at all.

Edit: This (by the creator of ABS) seems to state that it's impossible on a native ActionBar. I suppose I could just edit the two XML files that define his animation, but that will not give me full platform penetration.

Answer

HandlerExploit picture HandlerExploit · Jun 29, 2012

I use an overlay ActionBar

 requestWindowFeature(com.actionbarsherlock.view.Window.FEATURE_ACTION_BAR_OVERL‌​AY);

it doesn't show an animation when show()/hide() is called.