How to draw a line between menu item in navigation drawer

13,720

Give each group a unique id like this:

<group android:checkableBehavior="single"
android:id="@+id/group1">

It'll draw those lines for you between any two groups.

EDIT: Since the line is now showing but it's black on the black background, refer to this question to see how to change the color of the divider.

Share:
13,720
Dinesh Rijal
Author by

Dinesh Rijal

Updated on June 19, 2022

Comments

  • Dinesh Rijal
    Dinesh Rijal almost 2 years

    I want to highlight navigation items like this:

    highlighted item in navigation menu

    But my current menu looks like this:

    not highlighted item in navigation menu

    My menu.xml is

    <?xml version="1.0" encoding="utf-8"?>
        <menu xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto">
        <group android:checkableBehavior="single">
        <group android:checkableBehavior="single">
            <item android:id="@+id/home"
                android:title="Home"
                android:icon="@drawable/ic_action_home_page"/></group>
        <group android:checkableBehavior="single">
            <item android:id="@+id/p_profile"
                android:title="Payment Profile"
                android:icon="@drawable/ic_action_payment_profile"/></group>
        <group android:checkableBehavior="single">
            <item android:id="@+id/p_history"
                android:title="Payment history"
                android:icon="@drawable/ic_action_payment_history"/></group>
        <group android:checkableBehavior="single">
            <item android:id="@+id/m_cards"
                android:title="My cards"
                android:icon="@drawable/ic_action_my_card"/></group>
            <group android:checkableBehavior="single">
                <item android:id="@+id/menu_friends"
                    android:title="Friends"
                    android:icon="@drawable/search_people"/></group>
    
        <group android:checkableBehavior="single">
            <item android:id="@+id/notification"
                android:title="Notification"
                android:icon="@drawable/ic_action_notification"/></group>
        <group android:checkableBehavior="single">
            <item android:id="@+id/about"
                android:title="About"
                android:icon="@drawable/ic_action_about_us"/></group>
    
        </group>
    </menu>
    

    How can I create the above highlight effect?