In certain View
in my app I'm displaying a Fragment
with some Omages
in a RecyclerView
. When an Image
is clicked, a new detail Fragment
is shown (with an enter and return transition). The problem is when the Back Button
is pressed from the details View
, the shared element View
sometimes is gone and sometimes not.
This is how I call the new details Fragment
:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
dialog.setSharedElementEnterTransition(new DetailsTransition());
dialog.setEnterTransition(new Slide());
setExitTransition(new Fade());
dialog.setSharedElementReturnTransition(new DetailsTransition());
}
dialog.setTargetFragment(this, DETAIL_FRAGMENT);
getActivity().getSupportFragmentManager()
.beginTransaction()
.addSharedElement(view, transitionmage)
.replace(R.id.container, dialog, DetailFragment.TAG)
.addToBackStack(DetailFragment.TAG)
.commit();
I've already tried these solutions without success:
How to postpone a Fragment's enter transition in Android Lollipop?