How to prevent reverse shared element transition

android, android-transitions

Solution

I found a solution.

I have played around a bit and if you override `onBackPressed()` and call `finish()` instead of `super.onBackPressed()`, It works.

Problem

I have a litle problem. I have a fragment A with a list and an activity B with also a list. Now A and B have an image in common, so I set up an shared element transition and it works on the way from A to B. But I don't want to have the reverse transition if I press the back button. So I don't call in B `supportFinishAfterTransition` instead of `finish`. But now there is some ugly animation: B disappears normally except the image. The image stays in foreground until A is visible in the background and then disappears. How can I prevent this? I want the normal behavior like if I would call `finish` or `onBackPressed`. Greets

Original source