1

I want to have a group in my navigation drawer which has a title and next to the title there should be an edit button like in the new Google Keep App (see example below). Currently I can't find a sleek and working solution.

Google Keep example

My menu layout at the moment:

<?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">
    <item android:title="Accounts"
            app:actionLayout="@layout/edit_action"
            app:showAsAction="always"
            android:enabled="false">
        <menu>
            <group android:checkableBehavior="single">
                <item android:title="Item 1" android:icon="@drawable/ic_outline_calendar_today"/>
                <item android:title="Item 2" android:icon="@drawable/ic_outline_calendar_today"/>
            </group>
            <item android:title="Add new Item" android:icon="@drawable/ic_outline_add"/>
        </menu>
    </item>
    <group>
        <item android:title="Settings" android:icon="@drawable/ic_outline_settings"/>
        <item android:title="Trash" android:icon="@drawable/ic_outline_delete"/>
        <item android:title="Help \u0026 Feedback" android:icon="@drawable/ic_outline_feedback"/>
    </group>
</menu>

Currently only the title is displayed in the submenu but the edit button is missing. But if you just create an item without a menu child, the edit button will be displayed but the item is now an item and not a title as before.

I would like to have the same result as in the picture. The padding as well as the text size and color should be the default values from Android.

My edit_action.xml file looks like this:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        style="?android:attr/actionButtonStyle"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:clickable="true">
    <TextView
            android:text="Edit"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textColor="@color/colorPrimary"
            android:id="@+id/edit"/>
</RelativeLayout>

My menu looks like this at the moment:

Menu at the moment

4

0 回答 0