<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<androidx.drawerlayout.widget.DrawerLayout
android:id="@+id/drawerLayout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<!-- TODO (04) Add a fragment tag for the titleFragment in the LinearLayout
Use @+id/titleFragment for the android:id
Use com.example.android.navigation.TitleFragment for the android:name
Use match_parent for the layout_height and layout_width -->
<fragment
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/myNavHostFragment"
android:name="androidx.navigation.fragment.NavHostFragment"
app:navGraph="@navigation/navigation"
app:defaultNavHost="true">
</fragment>
</LinearLayout>
<com.google.android.material.navigation.NavigationView
android:id="@+id/navView"
android:layout_width="wrap_content"
android:layout_gravity="start"
app:headerLayout="@layout/nav_header"
app:menu="@menu/navdrawer_menu"
android:layout_height="match_parent">
</com.google.android.material.navigation.NavigationView>
</androidx.drawerlayout.widget.DrawerLayout>
</layout>
NavigationView has to be put at the end of DrawerLayout
NavigationView
has to be put at the end ofDrawerLayout