Shared element end listener

1k views Asked by At

I use addSharedElement() with fragments, and I want to know if there are possibilities to add a listener to execute some methods after the end of this transition. Thanks for the help.

1

There are 1 answers

2
azizbekian On BEST ANSWER

Fragment#setEnterSharedElementCallback(SharedElementCallback) does precisely that.

public class MyFragment extends Fragment {

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setEnterSharedElementCallback(new SharedElementCallback() {
            @Override
            public void onSharedElementEnd(List<String> sharedElementNames, List<View> sharedElements, List<View> sharedElementSnapshots) {
               // transition has ended 
            }
        });
    }
}