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
I found a solution.
I have played around a bit and if you override onBackPressed()
and call finish()
instead of super.onBackPressed()
, It works.
just stumbled upon this problem and there's a cleaner solution..
Just override finishAfterTransition(). You should have a boolean in your base class maybe, so it will look like this:
final override fun finishAfterTransition() {
if (myShouldAllowReverseTransitionsBoolean) {
super.finishAfterTransition()
} else {
super.finish()
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With