BottomNavView在片段之间的导航上保持隐藏 [英] BottomNavView remains hidden onNavigation between Fragments
问题描述
在此问题之前,我在BottomNavVew
和onDestinationChangedListener
中分别实现了HideBottomViewOnScrollBehaviour
和onDestinationChangedListener
fragment
控制BottomNavView
Prior to this question, i implemented the HideBottomViewOnScrollBehaviour
to the BottomNavVew
, and onDestinationChangedListener
in each fragment
to control the visiblity of the BottomNavView
错误::当我向下滚动并且BottomNavView
折叠/隐藏在FragmentA
中并且尝试导航到FragmentB
时,BottomNavView
保持隐藏,但是如果我滚动-重新弹出BNV
并尝试切换到相同的片段,BNV
变为可见,
Bug : when i scroll-down and the BottomNavView
collapse/hide in FragmentA
and i try navigating to the FragmentB
, the BottomNavView
remains hidden, but if i scroll-up justt for the BNV
to re-appear and try switching to the same fragment, the BNV
becomes visible,
任何人都可以帮忙做一个解释...吗?
can anyone help with an explanation...?
推荐答案
因为当您从A导航到B时,Fragment A中的侦听器将被Fragment A破坏.而Fragment B将不会接收,并且目的地更改,因为存在还没有变化.当您再次在片段B中对其进行初始化时,它不知道您来自A.
because when you navigate from A to B. The listener in Fragment A will be destroyed with Fragment A. And Fragment B will not receive and destination change because there is no change yet. As you init it again in Fragment B so it doesn't know you come from A.
只需将具有可见性逻辑的onDestinationChangedListener放在Activity中即可.
Just put the onDestinationChangedListener with visibility logic in Activity.
这篇关于BottomNavView在片段之间的导航上保持隐藏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!