Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ActionBar or ActionBarSherlock - Smoothly Hide / Show the ActionBar

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.

like image 781
Josh Avatar asked Jun 29 '12 19:06

Josh


1 Answers

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.

like image 196
HandlerExploit Avatar answered Sep 23 '22 19:09

HandlerExploit