I want to remove bottom Navigation bar while moving from one fragment to another fragment. This is how I am trying to remove bottom Navigation bar.
class LoadFragment : Fragment() {
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
// Inflate the layout for this fragment
val view = inflater.inflate(R.layout.fragment_load, container, false)
val bottomView = inflater.inflate(R.layout.activity_main, container, false)
bottomView.findViewById<BottomNavigationView>(R.id.bottom_home_navigation).visibility = View.GONE
return view
}
}
The bottom Navigation bar is present in Main Activity. I am trying to move from one fragment to another fragment but in that fragment there is no need of bottomNavigation bar. I don't know if it is possible or not. I am just trying new things.
CodePudding user response:
Write a function in your Activity
fun setBottomNavVisibility(visibility: Int){
YOUR_BOTTOM_NAV_VIEW.visibility =visibility
}
In your Fragment
// SHOW BOTTOM NAVIGATION
(requireActivity() as MainActivity).setBottomNavVisibility(View.VISIBLE)
// HIDE BOTTOM NAVIGATION
(requireActivity() as MainActivity).setBottomNavVisibility(View.GONE)