📜  android底部导航隐藏视图-Java代码示例

📅  最后修改于: 2022-03-11 14:52:34.700000             🧑  作者: Mango

代码示例1
private fun setupNav() {
    val navController = findNavController(R.id.nav_host_fragment)
    findViewById(R.id.bottomNav)
        .setupWithNavController(navController)

    navController.addOnDestinationChangedListener { _, destination, _ ->
        when (destination.id) {
            R.id.mainFragment -> showBottomNav()
            R.id.mineFragment -> showBottomNav()
            else -> hideBottomNav()
        }
    }
}

private fun showBottomNav() {
    bottomNav.visibility = View.VISIBLE

}

private fun hideBottomNav() {
    bottomNav.visibility = View.GONE

}