This is an Android navigation view (drawerlayout) question!

Asked 2 years ago, Updated 2 years ago, 36 views

Hello, everyone It's been a while since I posted a question I'm working on the navigation view, but this part is not working well, so I upload it like this.Navigationview took what was in the Android studio and used it! I want to remove that red part like the picture below.

<?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/nav_recommend"
            android:icon="@drawable/ic_menu_camera"
            android:checkable="true"
            android:title="recommended coffee" />
        <item
            android:id="@+id/nav_tools"
            android:icon="@drawable/ic_menu_gallery"
            android:title="Coffee Tools" />
        <item
            android:id="@+id/nav_kind"
            android:icon="@drawable/ic_menu_slideshow"
            android:title="Coffee Type" />
        <item
            android:id="@+id/nav_handdrip"
            android:icon="@drawable/ic_menu_manage"
            android:title="hand drip" />
        <item
            android:id="@+id/nav_store"
            android:icon="@drawable/ic_menu_manage"
            android:title="hand drip specialty store"
            />
    </group>
    <item android:title="@null">
        <menu>

            <item
                android:id="@+id/nav_setting"
                android:icon="@drawable/ic_menu_share"
                android:title="settings" />
            <item
                android:id="@+id/nav_information"
                android:icon="@drawable/ic_menu_send"
                android:title="Program Information" />
</menu>
    </item>
</menu>

When you do item android title="@null", there's a space like the first picture Is there a way to make a distinction like the second picture and make sure there's no space? Thank you for reading it.

android java

2022-09-22 13:26

1 Answers

Give the group an id and erase the menu. (The ID below was given randomly by me!)

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">

    <group
        android:id="@+id/test"
        android:checkableBehavior="single">
        <item
            android:id="@+id/nav_camera"
            android:icon="@drawable/ic_menu_camera"
            android:title="Import" />
        <item
            android:id="@+id/nav_gallery"
            android:icon="@drawable/ic_menu_gallery"
            android:title="Gallery" />
        <item
            android:id="@+id/nav_slideshow"
            android:icon="@drawable/ic_menu_slideshow"
            android:title="Slideshow" />
        <item
            android:id="@+id/nav_manage"
            android:icon="@drawable/ic_menu_manage"
            android:title="Tools" />
    </group>

    <group
        android:id="@+id/test1"
        android:checkableBehavior="single">
        <item
            android:id="@+id/nav_share"
            android:icon="@drawable/ic_menu_share"
            android:title="Share" />
        <item
            android:id="@+id/nav_send"
            android:icon="@drawable/ic_menu_send"
            android:title="Send" />
    </group>

</menu>


2022-09-22 13:26

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.