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. 


  1. Create a new style in style.xml. I created with name of drawerIcon.
  2. 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”.

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
         <item name="drawerArrowStyle">@style/DrawerIcon</item>
    </style>





Its all done. now run your app. 


Happy Coding. 

Comments

  1. Wow Great tutorial keep posting was really helpful :)

    ReplyDelete
  2. thanks alot! its simple way and its amazing!

    ReplyDelete
  3. thanks a lot, I was locking for it four hours.

    ReplyDelete
  4. Thanks a lot, I was locking for day.

    ReplyDelete
  5. wow... amazing how you made things so simple and easy. straight to the point! loved it! please keep posting things like that.

    ReplyDelete
    Replies
    1. Thanks. :) I am continuing my blogs in medium. Please follow.
      https://medium.com/@dev.amanchugh

      Delete
  6. p.s: i had to subscribe to your blog! congrats. =)

    ReplyDelete
  7. Replies
    1. in styles.xml, there is a style with name="MainTheme.Base. Copy the "@style/DrawerIcon" in there

      Delete
  8. Simple and perfect solution. Thanks a lot, I wasted entire day on it.

    ReplyDelete
  9. perfect solution, but is there a way to change the color dynamically?

    ReplyDelete
  10. Very helpful....thankyou

    ReplyDelete
  11. Worked ♥️ thanks a lot man

    ReplyDelete
  12. I 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?

    ReplyDelete
    Replies
    1. You 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.

      Delete
  13. Worked in older version but not in new

    ReplyDelete
  14. Kindly 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.

    ReplyDelete
  15. Hello, 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:

    1. 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

    ReplyDelete

Post a Comment

Popular posts from this blog

How to combine two Bitmap in Android

How to do Facebook Login with Custom Button Android