Reputation: 37645
In android, is it possible to put a listener on the animation you get between activities, so that code can be executed at the end of the animation?
Upvotes: 7
Views: 4288
Reputation: 81
Try this
Transition transition = getWindow().getSharedElementEnterTransition();
transition.addTarget(android.R.transition.slide_top);
transition.addListener(new Transition.TransitionListener() {
@Override
public void onTransitionStart(Transition transition) {
Log.e("transition ","onTransitionStart");
}
@Override
public void onTransitionEnd(Transition transition) {
Log.e("transition ","onTransitionEnd");
}
@Override
public void onTransitionCancel(Transition transition) {
}
@Override
public void onTransitionPause(Transition transition) {
}
@Override
public void onTransitionResume(Transition transition) {
}
});
Upvotes: 6
Reputation: 261
Do a post delay of 1 second in the onCreate(). The activity animation duration is the same length no matter what so doing (new Handler()).postDelayed(Runnable) should do the trick, just fine tune the delay.
Upvotes: 0