// activity_main.xml
<fragment
android:layout_width="match_parent"
android:layout_height="match_parent"
android:name="androidx.navigation.fragment.NavHostFragment"
android:id="@+id/nav_host_fragment"
app:navGraph="@navigation/mobile_navigation" />
// MainActivity.kt
val toolbar = findViewById<MaterialToolbar>(R.id.main_toolbar)
setSupportActionBar(toolbar)