prom85
prom85

Reputation: 17798

Android shared elements transition - wait for animation to finish

I have a list of elements and when I click one, I replace the fragment and use addSharedElement for the FragmentTransaction to animate the item in the list to become the header in the detail view.

Now I want to populate some details in the detail view, but only AFTER the header animation has finished. Because now, the header animation appears OVER the content and that does not look very good.

How can I achieve that?

Upvotes: 2

Views: 1566

Answers (1)

Kent
Kent

Reputation: 906

I hope I'm not too late. You can retrieve the shared elements transition from getWindow() then hook a listener to it.

getWindow().getSharedElementEnterTransition().addListener(new Transition.TransitionListener() {
    @Override
    public void onTransitionStart(Transition transition) {
        // put your code here        
    }
    ...
});

Upvotes: 4

Related Questions