I'm building an application based on Jetpack Navigation. Our UX designer has asked that in some cases, we use the same animation when transitioning between fragments that Android uses when launching a new activity.

Is there a setting I can use for this? Or is this a default animation that I can access via R.anim.something and use in my navigation graph? Is it defined in the AOSP source somewhere that I can copy? And does this vary per OEM?

1

There are 1 answers

0
ianhanniballake On BEST ANSWER

As per this issue, this is not possible:

Please consider adding an official API on Android R to get the animation used for the transition (and have CTS for it). Only using it, it will always be able to mimic it well.

The reason is that animation between Activities might be different between different OEMs, and that it doesn't even have to be static. I've seen some ROMs that let the user choose the animation between Activities.

So there is no API to retrieve the default activity animation, nor is that something that you can statically include in your app as every OEM may have a different animation and, even within a certain device, different OEM specific user settings may change what the default animation is.