Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Navigation drawer icon change color

Tags:

android

I want to change the color of navigation drawer icon(3 vertical bars) from white to grey. How do i do this in the simplest way?

<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:local="http://schemas.android.com/apk/res-auto"
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?attr/actionBarSize"
android:background="@color/grey"
local:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
local:popupTheme="@style/ThemeOverlay.AppCompat.Light" >

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Toolbar Title"
    android:id="@+id/toolbar_title"
    android:textColor="#010101" />
<!--android:layout_gravity="center"-->



</android.support.v7.widget.Toolbar>
like image 392
Abhi1988 Avatar asked Jan 20 '26 16:01

Abhi1988


2 Answers

You can change the icon itself programmatically, using something like this:

toolbar.setNavigationIcon(R.drawable.new_icon);
like image 138
frgnvola Avatar answered Jan 23 '26 09:01

frgnvola


Get the drawable

Drawable icMenu = ContextCompat.getDrawable(this, R.drawable.ic_hamburguer);

Tint the drawable

icMenu.setColorFilter(getResources().getColor(android.R.color.darker_gray), PorterDuff.Mode.SRC_ATOP);

Use it with the actionBar

actionBar.setHomeAsUpIndicator(icMenu);

actionBar.setDisplayHomeAsUpEnabled(true);

Or the toolbar

toolbar.setNavigationIcon(icMenu);

like image 41
Rodrigo Direito Avatar answered Jan 23 '26 09:01

Rodrigo Direito