Is there a way to get notified once this animation is complete?
Yes, but you'll have to use reflection. ActionBarImpl
uses an Animator
to monitor the show and hide animation, so you can attach your own AnimatorListener
to this Field
and receive the callback.
Here's an example:
private void monitorActionBarAnimation() {
final ActionBar actionBar = getActionBar();
try {
// Get the Animator used internally
final Class<?> actionBarImpl = actionBar.getClass();
final Field currentAnimField = actionBarImpl.getDeclaredField("mCurrentShowAnim");
// Monitor the animation
final Animator currentAnim = (Animator) currentAnimField.get(actionBar);
currentAnim.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
// Do something
}
});
} catch (final Exception ignored) {
// Nothing to do
}
}
Just make sure you use it after you call ActionBar.show
or ActionBar.hide
because it isn't initialized before those calls. Also, it's released in AnimatorListener.onAnimationEnd
so you'll need to call it each time.