简体   繁体   English

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

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

I'm building an application based on Jetpack Navigation.我正在构建一个基于 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.我们的 UX 设计师要求在某些情况下,在启动新活动时 Android 使用的片段之间转换时,我们使用相同的动画。

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?或者这是我可以通过 R.anim.something 访问并在我的导航图中使用的默认动画? Is it defined in the AOSP source somewhere that I can copy?它是否在我可以复制的 AOSP 源代码中定义? And does this vary per OEM?这是否因 OEM 而异?

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).请考虑在 Android R 上添加官方 API 以获取用于过渡的动画(并为其配备 CTS)。 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.原因是不同 OEM 之间活动之间的动画可能不同,而且它甚至不必是静态的。 I've seen some ROMs that let the user choose the animation between Activities.我见过一些 ROM 允许用户在活动之间选择动画。

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.因此,没有 API 来检索默认活动动画,也不是您可以静态包含在您的应用程序中的内容,因为每个 OEM 可能有不同的动画,即使在特定设备中,不同的 OEM 特定用户设置也可能会更改默认设置动画是。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我在活动和片段之间无法获得相同的动画 - I can't get the same animation between activity and fragments 当我使用提供Android Studio的活动抽屉导航模板时,如何使用片段在Drawerlayout上打开项目? - How can I use Fragments to open items on a Drawerlayout, when i used the Activity Drawer Navigation Template that provides android studio? 启动新活动时禁用活动滑入动画? - Disable activity slide-in animation when launching new activity? 当我在 JetPack Compose 中使用带有参数的导航时,为什么可以毫无问题地删除代码 navArgument? - Why can I remove the code navArgument without problem when I use Navigating with arguments in JetPack Compose? 使用标签导航时如何在片段之间传递数据? - How can I pass data between fragments when using tab navigation? 如何使用 Jetpack 的导航在片段中使用工具栏但不在活动中使用 - How can I use a toolbar in a fragment but not in activity using Jetpack's Navigation 使用 Jetpack Compose Navigation 时导航图是否已过时? - Is the navigation graph obsoleted when I use Jetpack Compose Navigation? Android:浏览片段时更改活动标题; 单击返回按钮时带回相同的标题 - Android: Change activity title when navigating fragments; Bring back same titles when back button clicked 如何使用 Jetpack 导航以编程方式关闭所有带有活动的片段 - How to close All fragments with activity programmatically using Jetpack navigation 使用捆绑启动活动时如何使用 ActivityTestRule? - How to use ActivityTestRule when launching activity with bundle?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM