首页 > 解决方案 > 是否可以在 Android 导航组件中为事务设置默认动画主题?

问题描述

我想像这样更改 Android 导航组件的默认事务动画:

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.MaterialComponents.Light.NoActionBar">
    <!-- Customize your theme here. -->
    <item name="enterAnim">@anim/slide_in_left</item>
    <item name="exitAnim">@anim/slide_out_left</item>
    <item name="popEnterAnim">@anim/slide_in_left</item>
    <item name="popExitAnim">@anim/slide_out_left</item>
</style>

在这种情况下,它不起作用。你有什么主意吗?

标签: androidanimationnavigationthemes

解决方案


导航的发行说明2.4.0-alpha02说:

通过 XML 膨胀元素时,动画属性可以使用从主题中提取的属性,使用 app:enterAnim="?attr/transitionEnter" 语法

所以,是的,现在可以为导航操作设置默认动画。


推荐阅读