问题
Prior to this question, i implemented the HideBottomViewOnScrollBehaviour
to the BottomNavVew
, and onDestinationChangedListener
in each fragment
to control the visiblity of the BottomNavView
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...?
回答1:
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.
Just put the onDestinationChangedListener with visibility logic in Activity.
来源:https://stackoverflow.com/questions/61646296/bottomnavview-remains-hidden-onnavigation-between-fragments