I'm trying to create a single activity Android application. I have MainActivity (only activity) with BottomNavigationView, three top level fragments and some child fragments. My requirement is whenever the screen is showing top level fragments, bottom navigation should be visible such that switching is possible. But when I'm viewing any of the child fragments, bottom navigation should be hidden. Is there any out-of-box way using the Navigation component or need to change the visibility manually ?

推荐答案

You have to make a method in MainActivity for visibility. Do call that method from fragments where you want to show or hide.

我在这种情况下面临的一个问题是,底部导航的可见性并没有完全消失.所以我将底部导航视图放在相对布局中,并隐藏父视图.

Kotlin相关问答推荐

在Kotlin中将ClosedRange字符串转换为List?<>

新的jOOQ Gradle插件无法正确处理自引用关系

两个LocalDateTime之间的Kotlin差异

Kotlin - 什么时候和什么时候不喜欢内联函数,为什么?

如何将glide显示的图像下载到设备存储中.Kotlin

如果不为空,则为 builder 设置一个值 - Kotlin

我们应该在 Effect 和 Either 之间 Select 哪个作为我们业务服务的返回类型?

具有多个不同类型来源的 LiveData

如何为你的 Flutter 元素添加 Kotlin 支持?

为什么 Kotlin 需要函数引用语法?

Kotlin 中 lambda 表达式中的默认参数

作为 Kotlin 中的函数的结果,如何从 Firestore 数据库返回列表?

Intellij 显示 build.gradle.kts 中的每一行都是红色的

将多个 Kotlin 流合并到一个列表中,而无需等待第一个值

Kotlin 的类型具体化使哪些在 Java 或 Scala 中无法实现的成为可能?

将ExpectedException与Kotlin一起使用

如何为kotlin异常生成SerialVersionId?

Gradle:无法连接到 Windows 上的 Kotlin 守护程序

导航架构组件 - 未生成 DestinationFragmentArgs

如何计算Kotlin中的百分比