Problem
I want to achieve shared element transition between Activity A and B, and between Activity B and C.
I did everything based on the android transition documentation.
There is no problem between:
A => B => back to A
A => B and B => C => back to B
But if I do:
The last step will not have any shared element transition (actually not only shared element transition, even there is only fading it could be lost).
I have been looking for solutions everywhere, but it seems everybody only needs A => B (and B => A) shared element transition but doesn't care any more transitions from B => C and back to A.
Example
See an example I created based on android's animation samples, where Activity A = MainActivity, B = DetailActivity, C = DetailDetailActivity. Clicking the button on Activity B will navigate to Activity C.
Because while executing C => B, it will re-construct a new EnterTransitionCoordinator for B, replacing the old one contains the correct mPendingExitNames
which it is important to indicate views need to be transitioned between A and B.
public boolean startExitBackTransition(final Activity activity) {
ArrayList<String> pendingExitNames = getPendingExitNames(); // here
if (pendingExitNames == null || mCalledExitCoordinator != null) {
return false;
} else {
// ...
}
}
The solution seems to be a little bit tricky. You can refer to ThreeActivityTransitionDemo and pay attention to the SharedElementUtils
.
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