4

I have implemented navigation drawer using DrawerLayout and NavigationView.

here is my drawer_view.xml

<menu xmlns:android="http://schemas.android.com/apk/res/android">
    <group android:id="@+id/group1" android:checkableBehavior="single">
        <item
            android:id="@+id/nav_home"
            android:icon="@drawable/ic_dashboard"
            android:title="Home" />

        <!-- Should I use android:actionLayout="@layout/custom"? -->
        <item
            android:id="@+id/nav_messages"
            android:icon="@drawable/ic_event"
            android:title="Messages" />
        <item
            android:id="@+id/nav_friends"
            android:icon="@drawable/ic_headset"
            android:title="Friends" />
        <item
            android:id="@+id/nav_discussion"
            android:icon="@drawable/ic_forum"
            android:title="Discussion" />
    </group>

    <group android:id="@+id/group2">
        <item
            android:icon="@drawable/ic_dashboard"
            android:title="Sub item 1" />
        <item
            android:icon="@drawable/ic_forum"
            android:title="Sub item 2" />
    </group>
</menu>

which results in;

enter image description here

I also want to display number of unread messages, like gmail app is displaying..

enter image description here

Should I use android:actionLayout to provide custom layout or is there any other way?

Rupesh
  • 3,415
  • 2
  • 26
  • 30
  • You need to make custom `ListView` or `RecyclerView` for this i guess. I don't think there is a way to do it using menus. – Sash_KP Jul 29 '15 at 10:16
  • What's the disadvantage to using app:actionLayout? That appears to be exactly its purpose? https://android.googlesource.com/platform/frameworks/support.git/+/master/design/src/android/support/design/internal/NavigationMenuItemView.java – nAndroid Mar 07 '16 at 21:42

1 Answers1

2

if you don't mind for using library , this library is suitable for you

https://github.com/mikepenz/MaterialDrawer

yemonkyaw
  • 52
  • 2
  • 6