BottomNavView remains hidden onNavigation between Fragments

痞子三分冷 提交于 2020-05-17 07:11:39

问题


Prior to this question, i implemented the HideBottomViewOnScrollBehaviour to the BottomNavVew, and onDestinationChangedListenerin 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!