How to change color of Hamburger icon of Navigation Drawer in android studio? [duplicate]
Asked Answered
A

4

5

I created a new activity with the default navigation drawer, but the default color is black, how to change it?

enter image description here

I tried this code works, but the animation is not running and can not be clicked

Drawable drawable = getResources().getDrawable(R.drawable.ic_menu);
        DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
        ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
                this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
        drawer.addDrawerListener(toggle);
        toggle.syncState();

        NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
        navigationView.setNavigationItemSelectedListener(this);
Amalea answered 13/3, 2018 at 9:16 Comment(0)
M
17

In Your AppTheme add this

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="drawerArrowStyle">@style/DrawerArrowStyle</item>
</style>

<style name="DrawerArrowStyle" parent="Widget.AppCompat.DrawerArrowToggle">
<item name="spinBars">true</item>
<item name="color">@android:color/white</item>
</style>
Malemute answered 13/3, 2018 at 9:19 Comment(5)
Thanks bro, it worksAmalea
No Need Of Thanks :) @RukySektiawanMalemute
Ya its working for thanksYlem
Yeap, it is working!Deon
in 2023 it is still woking.Jerz
C
-1

Add drawable pragmatically to toggle

 toggle.setDrawerIndicatorEnabled(false);
 toggle.setHomeAsUpIndicator(R.drawable.fi_menu);

where R.drawable.fi_menu is your custom drawable

Chancemedley answered 13/3, 2018 at 9:20 Comment(1)
The question is about color not drawable itself.Rubio
G
-1

You can change Navigation Drawer item icon and text color by following:

app:itemIconTint="#BDBDBD"
app:itemTextColor="#BDBDBD"

Add these in your Navigation drawer view.

Guenther answered 13/3, 2018 at 9:24 Comment(1)
This is used to tint icons in drawer item, not drawer toggle (hamburger icon)Longevity
V
-2

By Adding Background to Navigation view we can achieve that.

<android.support.design.widget.NavigationView
    android:id="@+id/nav_view"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="start"
    android:background="@color/bg_dark_color">
</android.support.design.widget.NavigationView>

Note:android:background="@color/bg_dark_color" this will help to change the background color.

Virescence answered 13/3, 2018 at 9:24 Comment(1)
His question is How to change color of Hamburger, not change color of background...please answers according the question.Ripleigh

© 2022 - 2024 — McMap. All rights reserved.