Search code examples
androidandroid-studionavigation-drawerandroid-toolbarandroid-studio-3.0

How to change color of Hamburger icon of Navigation Drawer in android studio?


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);

Solution

  • 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>