【问题标题】:Disabling animation when using Navigation Component together with BottomNavigationView将导航组件与 BottomNavigationView 一起使用时禁用动画
【发布时间】:2019-06-07 12:24:47
【问题描述】:

Navigation componentBottomNavigationView 一起使用时,如何禁用/更改渐变动画?

我将它们一起设置的代码(在活动中)如下:

    private fun setupBottomNavMenu() {
        val navController = Navigation.findNavController(this, R.id.main_navigation_fragment)
        val bottomNavigation = findViewById<BottomNavigationView>(R.id.bottom_navigation)
        NavigationUI.setupWithNavController(bottomNavigation, navController)
    }

【问题讨论】:

    标签: android bottomnavigationview android-jetpack android-jetpack-navigation


    【解决方案1】:

    添加动画默认文件,可以更改动画。

    res/anim/nav_default_enter_anim.xml
    res/anim/nav_default_exit_anim.xml
    res/anim/nav_default_pop_enter_anim.xml
    res/anim/nav_default_pop_exit_anim.xml
    

    如下所示,禁用动画。

    <?xml version="1.0" encoding="utf-8"?>
    <set xmlns:android="http://schemas.android.com/apk/res/android">
    </set>
    

    【讨论】:

    • 这个答案几乎是正确的!出于某种奇怪的原因,现在(2021 年第四季度)当将这些文件放入 res/animator 而不是 res/anim 时,它可以工作了。不要问我为什么。
    猜你喜欢
    • 2019-10-04
    • 1970-01-01
    • 1970-01-01
    • 2020-11-09
    • 2020-12-24
    • 2023-03-29
    • 1970-01-01
    • 2011-01-24
    • 1970-01-01
    相关资源
    最近更新 更多