Material-Animations
Material-Animations copied to clipboard
addSharedElement not work when using `add`
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.
I have no idea sorry. Maybe because when you call add
you are adding a new fragment instance, so your shared element can be referencing a view in the old one?
I don't get you. When I use replace
it works. The view is always referencing in the old one.
I think it's a bug. Now I use Activity with sharedElement and works well.
I think the document is clear enough, so... Don't you think?
I have the same problem. It seems like an official bug. It works When I use 'com.android.support:support-v4:25.1.0' and '24.2.1',but ‘25.3.1’ does not . Try to change the support version to 25.1.0 or other can be used.
I don't get you. When I use
replace
it works. The view is always referencing in the old one. I think it's a bug. Now I use Activity with sharedElement and works well. I think the document is clear enough, so... Don't you think?
Using replace it work fine
I have exact issues even with androidX. I have open a bug on issuetracker on google. Anyone have found a workaround?