Change Navigation Drawer menu icons

4

I would like to know how to change these icons:

Ifoundthescreen,butwhenIclickitdoesnotshowmethewaytomakethechange,butonlycolorsinRGBA:

    
asked by anonymous 04.05.2016 / 02:45

1 answer

5

I noticed that you are using the Navigation Drawer Pattern, so to change the icons and customize as you want, just go to the folder menu and the file activity_main_drawer.xml and make the changes as you want.

See an example:

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

    <item android:title="@string/menu1">
    <menu>
        <item
            android:icon="@drawable/ic_check_box"
            android:id="@+id/nav_um"
            android:title="@string/categoria1" />
        <item
            android:icon="@drawable/ic_check_box"
            android:id="@+id/nav_dois"
            android:title="@string/categoria2" />
        <item
            android:icon="@drawable/ic_check_box"
            android:id="@+id/nav_tres"
            android:title="@string/categoria3" />
        <item
            android:icon="@drawable/ic_check_box"
            android:id="@+id/nav_quatro"
            android:title="@string/categoria4" />
        <item
            android:icon="@drawable/ic_check_box"
            android:id="@+id/nav_cinco"
            android:title="@string/categoria5" />
        <item
            android:icon="@drawable/ic_check_box"
            android:id="@+id/nav_seis"
            android:title="@string/categoria6" />
    </menu>
    </item>
        <item android:title="@string/menu2">
        <menu>
            <item
                android:icon="@drawable/ic_check_box"
                android:id="@+id/nav_sete"
                android:title="@string/categoria7" />
            <item
                android:icon="@drawable/ic_check_box"
                android:id="@+id/nav_oito"
                android:title="@string/categoria8" />
            <item
                android:icon="@drawable/ic_check_box"
                android:id="@+id/nav_nove"
                android:title="@string/categoria9" />
            <item
                android:icon="@drawable/ic_check_box"
                android:id="@+id/nav_dez"
                android:title="@string/categoria10" />
        </menu>
    </item>
    <item android:title="@string/menu3">
        <menu>
            <item
                android:id="@+id/nav_sobre"
                android:icon="@drawable/ic_storage_24dp"
                android:title="@string/menusobre" />
            <item
                android:id="@+id/nav_sair"
                android:icon="@drawable/ic_clear_24dp"
                android:title="@string/menusair" />
        </menu>
    </item>

</menu>

Note that IDE Android Studio offers a very useful tool, which is Vector Asset for you to create a custom icon, to do this just right-click on the drawable > New > Vector Asset

Seeabovethatthenewiconisinthedrawablefolder,soyoujustneedtoedityouractivity_main_drawer.xmlfileinthisway:

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

        <item android:title="@string/menu1">
        <menu>
            <item
                android:icon="@drawable/ic_3d_rotation_black_24dp"
                android:id="@+id/nav_um"
                android:title="@string/categoria1" />

I hope I have helped.

    
04.05.2016 / 07:09