BottomNavView在片段之间的导航上保持隐藏 [英] BottomNavView remains hidden onNavigation between Fragments

本文介绍了BottomNavView在片段之间的导航上保持隐藏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此问题之前,我在BottomNavVewonDestinationChangedListener中分别实现了HideBottomViewOnScrollBehaviouronDestinationChangedListener fragment控制BottomNavView

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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆