awaistoor awaistoor - 5 months ago 150
Android Question

Remove subsection and from navigation drawer submenu

I want to remove the unwanted space created in submenu.

Is there any possibility I can achieve it from

menu.xml
class?

Here is my
navigation_drawer_menu.xml


<menu xmlns:android="http://schemas.android.com/apk/res/android">


<group android:checkableBehavior="single">
<item
android:id="@+id/all"
android:checked="true"
android:icon="@drawable/ic_channels"
android:title="All Channels" />
.......
<item
android:id="@+id/other"
android:icon="@drawable/ic_other"
android:title="Others" />

</group>

<item android:title="">
<menu>
<item
android:id="@+id/setting"
android:icon="@drawable/ic_action_settings"
android:title="Settings" />
<item
android:id="@+id/about"
android:icon="@drawable/ic_about"
android:title="About" />
<item
android:id="@+id/share"
android:icon="@drawable/ic_share"
android:title="Share" />
</menu>
</item>




Navigation drawer android

Thanks.

Answer

This is how I implement it. Because you are adding a title to a menu it is not recognizing it is empty.

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
    <group android:checkableBehavior="single">
        <item
            android:id="@+id/nav1"
            android:checked="true"
            android:title="Pos 1" />
        <item
            android:id="@+id/nav2"
            android:title="Pos 2" />

    </group>

    <group
        android:id="@+id/menu_two"
        android:checkableBehavior="single">
        <item
            android:id="@+id/pos3"
            android:title="Pos 3" />
        <item
            android:id="@+id/pos4"
            android:title="Pos 4" />

    </group>

</menu>
Comments