0

enter image description here

I am having some problems in displaying the component in navigation drawer. Although my code does not have any problem but the navigation drawer displays nothing. drawer_menu is component inside navigation drawer. Activity_main is navigation drawer itself

activity_main

<?xml version="1.0" encoding="utf-8"?>
<androidx.drawerlayout.widget.DrawerLayout 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:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/drawer_layout"
    android:fitsSystemWindows="true"
    tools:context=".MainActivity"
    tools:openDrawer="start">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

        <androidx.appcompat.widget.Toolbar
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="@color/colorPrimary"
            android:id="@+id/toolbar"
            android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
            app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
            android:elevation="4dp"/>
        <FrameLayout
            android:id="@+id/fragment_container"
            android:layout_width="match_parent"
            android:layout_height="match_parent"/>
    </LinearLayout>

        <com.google.android.material.navigation.NavigationView
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_gravity="start"
            android:id="@+id/nav_view"
            app:headerLayout="@layout/nav_header"
            app:menu="@menu/drawer_menu"/>
</androidx.drawerlayout.widget.DrawerLayout>

drawer_menu

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">

    <group android:checkableBehavior="single">
        <item android:id="@+id/nav_home"
            android:icon="@drawable/ic_home"
            android:title="Home"/>
        <item android:id="@+id/nav_profile"
            android:icon="@drawable/ic_profile"
            android:title="Profile"/>
        <item android:id="@+id/nav_settings"
            android:icon="@drawable/ic_settings"
            android:title="Setting"/>
        <item android:id="@+id/nav_offer"
            android:icon="@drawable/ic_offer"
            android:title="Offer"/>
        <item android:id="@+id/nav_off"
            android:icon="@drawable/ic_off"
            android:title="Logout"/>
    </group>
</menu>
random
  • 95
  • 1
  • 10

0 Answers0