Change color of Navigation Drawer Icon in Android Studio default template

纵饮孤独 提交于 2019-12-02 17:37:07

Based on @MD's comment, all I needed to do was add:

app:itemIconTint="@color/my_desired_colour"

to NavigationView (it is located in activity_main.xml layout file) The default tint is black but you can use an even darker shade of black by using #000000

 <android.support.design.widget.NavigationView
    android:id="@+id/nav_view"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:layout_gravity="start"
    android:fitsSystemWindows="true"
    app:headerLayout="@layout/nav_header_main"
    app:itemIconTint="#000000"
    app:menu="@menu/activity_main_drawer" />
Pablo Cegarra

Create a new style:

<style name="DrawerIconStyle" parent="Widget.AppCompat.DrawerArrowToggle">
    <item name="color">@android:color/red</item>
</style>

and in your theme, add this line:

<item name="drawerArrowStyle">@style/DrawerIconStyle</item>

Based on @ojonugwa ochalifu and @MD's comment,

You can achieve by writing app:itemIconTint but if you write this, the navigation drawers icon color will also be changed. The simple and easy solution that I found after lots of R&D is that you have define <item name="colorControlNormal">#FFE730</item> in theme of AppBarLayout or if you using Toolbar only without AppBarLayout, you can also write <item name="colorControlNormal">#FFE730</item> in theme or popupTheme of Toolbar in your xml.

This will also change the color of activity's back arrow as well.

Hope this helps you all who are facing this type of issue.

In my case, I was having a style

 <style name="MyToolbarStyle" parent="Theme.AppCompat">
     <item name="actionOverflowButtonStyle">@style/ActionButtonOverflowStyle</item>
     <item name="drawerArrowStyle">@style/DrawerArrowStyle</item>
 </style>
 <style name="ActionButtonOverflowStyle">
        <item name="android:color">@color/colorPrimary</item>
    </style>
    <style name="DrawerArrowStyle">
        <item name="android:color">@color/colorPrimary</item>
    </style>

and have applied the theme to the Appbar layout, so programatically chaining color didn't work.

So, try removing any styles that you applied, in case you are not able to change the color of the icon and then try the above given solutions.

You must change the colorAccent in the colors file to which ever color you want :

  <color name="colorAccent">whichever color required</color>

This solution worked for me

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!