Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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)?

enter image description here

like image 733
Shaddow Avatar asked Jun 18 '15 13:06

Shaddow


1 Answers

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> 
like image 100
Moinkhan Avatar answered Oct 19 '22 06:10

Moinkhan