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.
Asked
Active
Viewed 1,017 times
1
azizbekian
- 60,783
- 13
- 169
- 249
Ruslan Leshchenko
- 4,043
- 4
- 24
- 36
1 Answers
3
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
}
});
}
}
azizbekian
- 60,783
- 13
- 169
- 249
-
I didn't find any methods which can help me. Could you please help me? – Ruslan Leshchenko Feb 20 '18 at 16:26
-
Thanks, I'll try it – Ruslan Leshchenko Feb 20 '18 at 16:33