Cancel Shared Return Transition on Android Lollipop
Asked Answered
W

0

7

I was playing around with Lollipop's Activity Transition.

I have a button in Activity A which when clicked calls Activity B. In the Activity B, I am overriding onBackPressed() and calling finishAfterTransition()

Activity B just has two relative layout blocks with the background color. I have put a shared element transition from the Button to one of the blocks and it works perfectly. Even the return transition works.

But the problem I am having is that I am not able to cancel the shared element return transition and implement a normal exit transition.

The intent was to slide the two blocks off the screen, top one off the top and bottom one off the bottom. That's not working if I have a shared element transition enabled.

I tried setting the exit transition and setting null to sharedElementReturn transition on Activity B. Not working.

I tried setting the reenter transition on Activity A with the slide transition, but still, the shared element transition is reversed on the back press.

If I turn off the shared element transition, the desired effect is perfect on return from Activity B to A.

Any ideas?

Within answered 2/4, 2015 at 2:53 Comment(4)
I played around a bit and managed to turn off the return transition by setting the SharedReturnTransition on Activity B, but I still can't get it animated on finishAfterTransition()Within
Do you have a video (i.e. generated using Android Studio's screen capture feature) illustrating the bug? It's hard to visualize the problem you are describing. Some code might help too.Wirephoto
I'll try and get the video. Right now I am in office and don't have access to my personal laptop. Till that time, the effect I was trying to achieve can be seen in the Google Play Store app. When you click on an app, the icon is "shared element transition"-ed to the next screen. And on back press, the top and bottom part slides off screen.Within
If you don't want to use the return transition, you can just call finish() in Activity B instead of finishAfterTransition().Embarrassment

© 2022 - 2024 — McMap. All rights reserved.