I have tried to read this but my problem is little bit different.
I need some different toolbars, so according the documentation from here , I need to set the toolbar in each of my fragment not in my MainActivity.
so I set the toolbar in each xml of my fragment. and then in each fragment I use this code to set the toolbar
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
val toolbar = view.findViewById<androidx.appcompat.widget.Toolbar>(R.id.toolbar3)
val navHostFragment = NavHostFragment.findNavController(this);
NavigationUI.setupWithNavController(toolbar, navHostFragment)
}
but I have back button in top level fragment of my bottom navigation view like the image below. I am confused how to pass appBarConfiguration if I set the toolbar from my fragment not from my MainActivity