addSharedElement not work when using `add`
Author: DanteAndroidCreated Mar 15, 2017Updated Nov 19, 2018
Fragment fragment = ViewerFragment.newInstance(diary.getPhotoUrl());
fragment.setSharedElementEnterTransition(new ChangeBounds());
getFragmentManager().beginTransaction()
.hide(this)//either using hide or not won't work
.add(R.id.container, fragment)// it work when using replace
.addToBackStack("")
.addSharedElement(attachPicture, attachPicture.getTransitionName())
.commit();Could you tell me why is that? Because I read the document of addSharedElement, it says:
Used with custom Transitions to map a View from a removed or hidden Fragment to a View from a shown or added Fragment.
Source: lgvalle/Material-Animations