Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change color of Navigation Drawer Icon in Android Studio default template

The new default Navigation Drawer Activity template in Android Studio

enter image description here

defines its titles and icons in a menu file activity_main_drawer like this:

<group android:checkableBehavior="single">     <item         android:id="@+id/nav_camara"         android:icon="@drawable/ic_action_emo_cool"         android:title="Import" />     <item         android:id="@+id/nav_gallery"         android:icon="@android:drawable/ic_menu_gallery"         android:title="Gallery" />     <item         android:id="@+id/nav_slideshow"         android:icon="@android:drawable/ic_menu_slideshow"         android:title="Slideshow" />         ... 

The first item in my example uses a red icon:

enter image description here

but when I run the app, the color of the icon remains black.I have tested this for blue, green, yellow and purple icons, but the result is the same.

enter image description here

I read somewhere that the toolbar should use ThemeOverlay.AppCompat.Dark.ActionBar and my app already uses this in the styles.xml file:

<resources>  <!-- Base application theme. --> <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">     <!-- Customize your theme here. -->     <item name="colorPrimary">@color/colorPrimary</item>     <item name="colorPrimaryDark">@color/colorPrimaryDark</item>     <item name="colorAccent">@color/colorAccent</item> </style> <style name="AppTheme.NoActionBar">     <item name="windowActionBar">false</item>     <item name="windowNoTitle">true</item> </style> <style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" /> <style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" /> 

Initially I thought this had something to do with Android Studio's cache feature so I invalidated cache and restarted Android Studio with no luck.

like image 227
Ojonugwa Jude Ochalifu Avatar asked Oct 29 '15 06:10

Ojonugwa Jude Ochalifu


People also ask

How do I change the color of the drawer icon?

To change the drawer icon color in Flutter: Simply add the iconTheme property inside the AppBar widget and assign the IconThemeData(color: [your_color]).


2 Answers

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" /> 
like image 135
Ojonugwa Jude Ochalifu Avatar answered Sep 19 '22 03:09

Ojonugwa Jude Ochalifu


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> 
like image 26
Pablo Cegarra Avatar answered Sep 20 '22 03:09

Pablo Cegarra