Android NavigationView menu group divider [duplicate]
Android support design library provide NavigationView:
<android.support.design.widget.NavigationView
...
app:menu="@menu/navigation_drawer_items" />
menu/navigation_drawer_items:
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<group android:checkableBehavior="single">
<item .../>
...
</group>
<group android:checkableBehavior="single">
<item .../>
...
</group>
</menu>
How to add divider, separator or space between groups (like on picture)?
Just give a unique id to each group. It will create a separator automatically.
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<group android:id="@+id/group_feature"
android:checkableBehavior="single">
<item android:id="@+id/navdrawer_item_map"
android:checked="true"
android:icon="@drawable/ic_drawer_map"
android:title="@string/navdrawer_item_map"/>
</group>
<group android:id="@+id/group_settings"
android:checkableBehavior="single">
<item android:id="@+id/navdrawer_item_settings"
android:icon="@drawable/ic_drawer_settings"
android:title="@string/navdrawer_item_settings"/>
</group>
</menu>
you do something like this.
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<group android:checkableBehavior="single">
<item
android:id="@+id/nav_home"
android:icon="@drawable/ic_dashboard"
android:title="Home" />
<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>
<item android:title="Sub items">
<menu>
<item
android:icon="@drawable/ic_dashboard"
android:title="Sub item 1" />
<item
android:icon="@drawable/ic_forum"
android:title="Sub item 2" />
</menu>
</item>
</menu>
this code is taken from the Design Library example app made by Chris Barnes https://github.com/chrisbanes/cheesesquare