How to change the color of Hamburger icon in Toolbar Android
Hello friends,
This tutorial is for changing Hamburger color on toolbar.
The default colors of Hamburger Navigation icon is white and black but we can change the color of hamburger icon.
- Create a new style in style.xml. I created with name of drawerIcon.
-
extends style by “Widget.AppCompat.DrawerArrowToggle”.
<style name="DrawerIcon" parent="Widget.AppCompat.DrawerArrowToggle"> </style>
3. Add item color with given color code which color you want for hamburger.
<style name="DrawerIcon" parent="Widget.AppCompat.DrawerArrowToggle"> <item name="color">@color/color_icon</item> </style>
4. Go to your main theme class. I have “AppTheme”.
5. Add your drawer theme to main theme with name of “drawerArrowStyle”.
5. Add your drawer theme to main theme with name of “drawerArrowStyle”.
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> <item name="drawerArrowStyle">@style/DrawerIcon</item> </style>
Wow Great tutorial keep posting was really helpful :)
ReplyDeleteMA NEMOJ
ReplyDeleteThnq
ReplyDeleteThanks its work fine
ReplyDeletethanks alot! its simple way and its amazing!
ReplyDeletethanks a lot, I was locking for it four hours.
ReplyDelete:)
DeleteTANKS BRO
ReplyDeleteThanks a lot, I was locking for day.
ReplyDeletewow... amazing how you made things so simple and easy. straight to the point! loved it! please keep posting things like that.
ReplyDeleteThanks. :) I am continuing my blogs in medium. Please follow.
Deletehttps://medium.com/@dev.amanchugh
p.s: i had to subscribe to your blog! congrats. =)
ReplyDeletesuper
ReplyDeletewhere is main theme??
ReplyDeletein styles.xml, there is a style with name="MainTheme.Base. Copy the "@style/DrawerIcon" in there
DeleteSimple and perfect solution. Thanks a lot, I wasted entire day on it.
ReplyDeleteperfect solution, but is there a way to change the color dynamically?
ReplyDeleteperfect.. big thanks sir
ReplyDeleteVery helpful....thankyou
ReplyDeleteWorked ♥️ thanks a lot man
ReplyDeleteI am using a toolbar. I need black hamburger menu icon on white background. What I am getting is a grayish background. How do we change this?
ReplyDeleteYou need to delete the default code for the gray background. What I cannot figure out is how to follow these directions to change the hamburger menu. I just started and these directions are a bit skimpy. Could you help? Thank you.
Deletei like your tavhing
ReplyDeletei like your teaching
ReplyDeleteWorked in older version but not in new
ReplyDeletethanks!
ReplyDeleteKindly guide for android 4.1.2 version because I've 2 separate files named values/theme.xml and night/themes.xml instead of style.xml.
ReplyDeleteHello, I am struggling with this also and there seem to very little on the internet how to do this. It's only my second day playing with html and I do not understand these directions:
ReplyDelete1. Create a new style in style.xml. I created with name of drawerIcon.
HOW DO YOU "CREATE A NEW STYLE"?
WHAT IS DRAWERCON? CAN I JUST USE A READY ONE?
2. extends style by “Widget.AppCompat.DrawerArrowToggle”.
WHAT DOES IT MEAN "EXTENDS STYLE" BY? AND IS THAT HOW I AM SUPPOSED TO NAME MY FILE OR IT'S IN THE CONTEMPO HTML CODE?
3. Go to your main theme class. I have “AppTheme”.
I ALREADY TRIED TO FIND IT IN THE "THEME CLASS"... For hours. Can you be more specific. How to find it? Which line of code exactly would it be in the template?
4. RUN MY APP... How is it my app? I thought it was code and gadgets / widgets? That's confusing.
Please help. I have managed find and modify so much already, but with a WHITE background if the hamburger menu won't show then all the other work is for nothing.
Looking things up in the code and changing them: heighs, colors, etc. is easy, but this is too complicated.
Thank you, J