Chandrakishore Reddy
Chandrakishore Reddy

Reputation: 33

My android studio preview for navigation drawer is not showing menu icons

Below is my xml code for navigation drawer with menu icons, I have included tools:navigation view in the below code for navigation drawer. Before including the tools:navigation_view, my menu icons were aligned towards the right side of screenScreenshot of my UI after including navigation_view[][1[Screenshot of myUI before including tools_navigation]]2

xmlns:tools="http://schemas.android.com/tools"
  tools:showIn="navigation_view">

<group android:checkableBehavior="single">
    <item android:id="@+id/nav_account"
        android:icon="@drawable/ic_account"
        android:title="Account"/>
    <item android:id="@+id/nav_walk"
        android:icon="@drawable/ic_transfer_within_a_station_black_24dp"
        android:title="Walk"/>
    <item android:id="@+id/nav_train"
        android:icon="@drawable/ic_subway"
        android:title="Train"/>
</group>
<item android:title="Self">
    <menu>
        <item android:id="@+id/nav_byroad"
            android:icon="@drawable/ic_time_to_leave_black_24dp"
            android:title="By road"/>
        <item android:id="@+id/nav_traffic"
            android:icon="@drawable/ic_traffic_black_24dp"
            android:title="Traffic"/>
    </menu>
</item>

Upvotes: 0

Views: 150

Answers (1)

ACR
ACR

Reputation: 377

To see the preview of the menu in the drawer, you can add tools:openDrawer="start" in the drawerlayout component in the xml.

Example:

<androidx.drawerlayout.widget.DrawerLayout
        android:id="@+id/drawer"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:openDrawer="start">

Upvotes: 1

Related Questions