Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Is it possible to remove bottomNavigation Bar while moving from one fragment to another fragment?

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.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

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)
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading