3

I have a RecyclerView inside the fragment in a Viewpager and sharing element from an item in the RecyclerView to a DetailActivity containing a fragment. I am setting transition inside the DetailActivity for the entry and exit of the fragment.

public static void sharedTransitionReceiver(Activity activity, Fragment fragment) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        activity.getWindow().getEnterTransition().setDuration(500);
        Slide slideTransition = new Slide(Gravity.START);
        slideTransition.setDuration(500);
        fragment.setReenterTransition(slideTransition);
        fragment.setExitTransition(slideTransition);
        fragment.setSharedElementEnterTransition(new ChangeBounds());
    }
}

It is working just fine but when I navigate back to the previous activity containing the Viewpager exit animations are not working and item won't animates back to their original position.

mihirjoshi
  • 12,161
  • 7
  • 47
  • 78

1 Answers1

5

After 4 hours of effort, I cannot imagine the answer to be that simple. I was calling finish() after popping out every fragment from stack instead I have to use supportFinishAfterTransition();.

mihirjoshi
  • 12,161
  • 7
  • 47
  • 78