19

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.

Community
  • 1
  • 1
Josh
  • 12,448
  • 10
  • 74
  • 118

1 Answers1

17

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.

Blundell
  • 75,855
  • 30
  • 208
  • 233
HandlerExploit
  • 8,131
  • 4
  • 31
  • 50
  • 4
    What's an overlay ActionBar? Can you provide more info? – greg7gkb Jul 25 '12 at 23:21
  • 1
    `requestWindowFeature(com.actionbarsherlock.view.Window.FEATURE_ACTION_BAR_OVERLAY);`, – Salw Sep 18 '12 at 08:50
  • 2
    Official documentation on the subject: http://developer.android.com/reference/android/view/Window.html#FEATURE_ACTION_BAR_OVERLAY – ol_v_er Jun 20 '13 at 18:01
  • 1
    An overlay ActionBar is a fully or partial transparent ActionBar. It is not related with this question but to allow the overlay ActionBar from your styles file put the following in your theme true true – Carlos Feb 17 '14 at 19:26
  • You have to call this before anything else in your onCreate() Method. It works like a charm. – Munchies Jun 27 '14 at 16:09