Currently I have three options in my bottom navigation and a navigation graph for them.
part of my mainActivity.xml file look like this:
<fragment
android:id = "@+id/nav_host_fragment"
android:layout_width = "match_parent"
android:layout_height = "0dp"
android:layout_weight = "1"
android:name = "androidx.navigation.fragment.NavHostFragment"
app:navGraph = "@navigation/nav_graph"
app:defaultNavHost = "true" />
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id = "@+id/bottom_nav"
android:layout_width = "match_parent"
android:layout_height = "wrap_content"
app:menu = "@menu/bottom_nav" />
and In my mainActivity I have written this code,
navController = Navigation.findNavController(this, R.id.nav_host_fragment)
bottom_nav.setupWithNavController(navController)
NavigationUI.setupActionBarWithNavController(this, navController)
everything related to navigation is handled by jetpack navigation library. Now I want to add a Navigation drawer also and in drawer I want to add different menu items(not only three that are in bottom navigation), so I will add new menu resource file for navigation drawer, now how should I use navigation library for both bottom nav and nav drawer? I don't want to manually do Fragment transactions and work with fragment manager.
One approach that I can think of is adding all of the fragments in a single nav graph(which is currently used for bottom nav) and then use the same navController for nav drawer also but I am looking for a better approach.