Paul Boddington
Paul Boddington

Reputation: 37645

Putting a Listener on the transition animation between activities

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

Answers (2)

Arman Chatikyan
Arman Chatikyan

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

Clint Deygoo
Clint Deygoo

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

Related Questions