I am using the technique here to animate an activity into life. But I don't want the action bar to show until after the animation is complete. If I set action bar to hide and then to show in onResume, it's as if I never hid it. does anyone know how to do this?
Asked
Active
Viewed 344 times
1
-
sounds like you need to set a callback on that animation for once it's finished then you want to show the actionbar, take a look at this question http://stackoverflow.com/questions/3386116/set-animation-listener-to-activity-animations – Eluvatar Dec 04 '13 at 23:01
1 Answers
0
Create an animation and set a callback:
Animation anim = AnimationUtils.loadAnimation(context,R.anim.an_animation);
anim.setAnimationListener(new AnimationListener() {
public void onAnimationEnd() {
// code to show actionbar
}
public void onAnimationStart() {}
public void onAnimationRepeat() {}
}
and then proceed to add the animation to the view and start it
EDIT: I just read you meant to animate an Activity
, not a View
. Since Activity
does not provides any method to set animation callbacks, you could create an AyncTask
, in the onCreate
method of the second Activity
, that will wait the same time as the animation. If the animation goes for 500ms, then your AsyncTask
will wait 500ms and then shows the ActionBar
:
public class SecondActivity {
private ActionBar bar;
protected void onCreate(Bundle savedInstanceState) {
bar = getActionBar();
bar.hide();
new AsyncTask<Void,Void,Void>() {
@Override
public void doInBackground(Void params...) {
Thread.sleep(500);
bar.show();
return null;
}
}.execute();
}
}

Christopher Francisco
- 15,672
- 28
- 94
- 206
-
Will you please elaborate on "proceed to add animation to the view"? I am starting a new activity. Did you see the link I provided under "here"? Thanks. – Cote Mounyo Dec 05 '13 at 02:09