【问题标题】:Bottom navigation with navigation component when fragment load flickering happens发生片段加载闪烁时带有导航组件的底部导航
【发布时间】:2020-06-23 05:58:48
【问题描述】:
我目前正在使用带有导航组件的底部导航,它工作正常,但是当我们单击导航项片段正在加载时,会发生闪烁,即使当前项目也被选中,也会发生闪烁。它在片段加载时发生。我的应用程序屏幕背景在白色时不是白色的,没有闪烁显示我已经尝试了所有可用的解决方案。
我已经更改了谷歌导航示例应用程序的背景颜色,然后我也可以看到闪烁。
如果有人有任何解决方案,请在此处发布。
【问题讨论】:
标签:
android
navigation
bottomnavigationview
flicker
【解决方案1】:
由于底部导航使用的默认交叉淡入淡出动画而发生闪烁。您可以通过在res\animator 包中创建以下文件来覆盖动画。
nav_default_enter_anim.xml
nav_default_exit_anim.xml
nav_default_pop_enter_anim.xml
nav_default_pop_exit_anim.xml
这应该是那些文件的内容。
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Overwrite the default animation. -->
</set>
【解决方案2】:
我已经找到解决我闪烁的问题的解决方案,因为我的背景颜色是黑色,如果我将其更改为白色,我没有任何闪烁,我通过添加波纹管更新主题。
<item name="android:windowBackground">#000000</item>
<item name="android:colorBackground">#000000</item>
通过添加这些行,我避免了闪烁问题。