Coming back for transition fragment shared element gone
Asked Answered
M

0

7

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?

Postponed Shared Element Transitions

Maxon answered 15/3, 2017 at 11:31 Comment(2)
Can you post a simple project in github?Xanthe
did you find a solution?Wot

© 2022 - 2024 — McMap. All rights reserved.