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

4 Answers4

16

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>
matin sayyad
  • 575
  • 3
  • 10
-1

Add drawable pragmatically to toggle

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

where R.drawable.fi_menu is your custom drawable

Anil
  • 1,605
  • 1
  • 14
  • 24
-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.

Gowthaman M
  • 8,057
  • 8
  • 35
  • 54
-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.

Akila
  • 715
  • 2
  • 8
  • 13
  • His question is How to change color of Hamburger, not change color of background...please answers according the question. – Abed Putra Dec 07 '18 at 09:11