How to add a collapsible menu item inside navigation drawer in android?
<p>I have a <code>DrawerLayout</code> enclosing a <code>NavigationView</code> and this layout activity serves as a common Navigation drawer for all the activities in my app. I am providing the menu resource for <code>app:menu</code> in navigation view. I have some menu items, but I want one menu item to be collapsible/expandable, so that when I click on it, it expands to show two submenus and collapses again on a second click.</p>

<p>I have added submenus by adding another <code>&lt;menu&gt;</code> inside the <code>&lt;item&gt;</code> but cant make it collapsible/expandable.</p>

<p>Additionally, I don't want to use <code>ExpandableListView</code> for my purpose. Instead, I just need to do some tweaks in menu resource file. Please just point me in the correct direction. I have searched Google only to find code, blogs, and examples for collapsible list items using <code>ExpandableListView</code>, but I need it to work with the <code>NavigationView</code> design widget from the design support Library.</p>

<p>Here's my code for the menu file:</p>

<pre><code>&lt;menu xmlns:android="http://schemas.android.com/apk/res/android"&gt;

&lt;group android:checkableBehavior="single"&gt;
    &lt;item
        android:id="@+id/nav_aboutus"
        android:title="About Us" /&gt;

    &lt;item
        android:id="@+id/nav_faq"
        android:title="FAQs" /&gt;
    &lt;item
        android:id="@+id/nav_share"
        android:title="Share" /&gt;
    &lt;item
        android:id="@+id/nav_myaccount"
        android:title="My Account" /&gt;
    &lt;item
        android:id="@+id/nav_legal"
        android:title="Legal" &gt;
        &lt;menu&gt;
                &lt;item
                    android:id="@+id/nav_tnc"
                    android:title="Terms and Conditions" /&gt;
                &lt;item
                    android:id="@+id/nav_pp"
                    android:title="Privacy Policy" /&gt;
            &lt;/group&gt;
        &lt;/menu&gt;
    &lt;/item&gt;

&lt;/menu&gt;
</code></pre>

<p>I want Legal menu item to be expandable having two submenu items 'Terms and Conditions', 'Privacy Policy'.</p>