Jetpack 导航:在片段之间导航时,如何使用与启动新 activity 时相同的动画?

Jetpack Navigation: When navigating between fragments, how can I use the same animation as when launching a new activity?

我正在构建一个基于 Jetpack Navigation 的应用程序。我们的用户体验设计师要求,在某些情况下,我们在 Android 启动新的 activity.

时使用的片段之间的转换使用相同的动画

是否有我可以使用的设置?或者这是我可以通过 R.anim.something 访问并在我的导航图中使用的默认动画?它是否在我可以复制的 AOSP 源代码中定义?这是否因 OEM 而异?

根据 this issue,这是不可能的:

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.

所以没有 API 来检索默认的 activity 动画,也不是您可以静态包含在您的应用程序中的东西,因为每个 OEM 可能有不同的动画,甚至在某些设备、不同的 OEM 特定用户设置可能会更改默认动画。