Alex Wih Alex Wih - 1 month ago 12
Android Question

How to know when enter transition ended on Fragment?

I have a fragment, which shows enter animation, I set transition by

this.setEnterTransition(transition);


After that I want to show another animation. But I need to know when transition animation ends to start the second one.

For activity there is a callback like
onEnterAnimationComplete()
but it is not called when Fragment's transition ends.

Is there any way to know when enter transition ends for the Fragment?

Answer Source
transition.addListener(new Transition.TransitionListener() {
                    @Override
                    public void onTransitionStart(Transition transition) {}

                    @Override
                    public void onTransitionEnd(Transition transition) {}

                    @Override
                    public void onTransitionCancel(Transition transition) {}

                    @Override
                    public void onTransitionPause(Transition transition) {}

                    @Override
                    public void onTransitionResume(Transition transition) {}
                });

                this.setEnterTransition(transition);