Help me out please.
Intro: I use Navigation Component, Single Activity pattern with 3 fragments switched via bottom navigation menu. Also I have Drawer Navigation.
All fragments are of the same level (all are root, accessed directly from bottm nav)
How things should be: For all fragments there must be a toolbar with hamburger icon for the drawer.
Problem: when app starts, the home fragment shows standard hamburger icon for drawer, which is ok. But when I switch to any other fragment, the drawer icon turns into arrow icon.
Furthermore, when ths arrow is pressed, the drawer slides from left. It means it still works as a button for showing the Drawer menu, but only icon changed.
Question: How can I disable transformation of hamburger icon into arrow icon when switching to another fragments from bottom navigation menu?
Files:
Navigation Graph:
<navigation xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/nav_graph"
app:startDestination="@id/bottom_nav_proposals"
>
<fragment
android:id="@id/bottom_nav_proposals"
android:name="com.base.ProposalsContainerFragment"
android:label="fragment_proposals"
tools:layout="@layout/fragment_proposals" />
<fragment
android:id="@id/bottom_nav_vehicles"
android:name="com.base..DriversVehiclesFragment"
android:label="Vehicles" >
</fragment>
<fragment
android:id="@id/bottom_nav_drivers"
android:name="com.bijov1apps.base.carrier.root.drivers.DriversVehiclesFragment"
android:label="Drivers" >
</fragment>
</navigation>
Activity:
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
//initializing Navigation COmponent
val navHostFragment = supportFragmentManager.findFragmentById(R.id.nav_host_carrier_root) as NavHostFragment
val navController = navHostFragment.navController
//setting up toobar stuff
val toolbar: Toolbar = findViewById(R.id.toolbar_root)
toolbar.setupWithNavController(navController, drawerLayout)
//setting up navigation drawer stuff
val drawerLayout:DrawerLayout = findViewById(R.id.drawer_layout)
val navView: NavigationView = findViewById(R.id.nav_view)
val toggle = ActionBarDrawerToggle(
this, drawerLayout, toolbar, R.string.navigation_drawer_open,
R.string.navigation_drawer_close
)
drawerLayout.addDrawerListener(toggle)
toggle.syncState()
navView.setNavigationItemSelectedListener(this)
//setting up bottom navigation menu stuff
val bottomNavigationView = findViewById<BottomNavigationView>(R.id.logisticBottomBar)
bottomNavigationView.setupWithNavController(navController)
}
Navigation Graph
and in the menu XML file are matching. Refer to this Video for more information: youtu.be/wv5VFEcnb-8?t=217 (The video will start at the correct timestamp when he explains the IDs). – René Jörg Spies@+id/
which is wrong in your case. – René Jörg Spies