Materialdrawer: Badge on hamburger menu icon

Created on 4 Feb 2016  Â·  6Comments  Â·  Source: mikepenz/MaterialDrawer

Hello,

I am implementing this Nav Drawer in my app and I have badges working great. My only question is how do I get the badge to appear on the hambuger menu icon when the Nav Drawer is collapsed? When an event happens in my app, I would like to update not only the DrawerItem with a badge count but also the hamburger menu icon if it happens to be collapsed. I would like similar functions like the Ebay app.

wzzdc

Is this possible?

Thanks!

good to know question

Most helpful comment

To all those who are interested, this is what I did.

Make sure that you remove the .withToolbar() when creating the DrawerBuilder. This will have to be managed manually.

In your toolbar layout, add the following:

badge

Create this drawable to use as the background:

drawable

You will have to hook up a click listener to the nav_drawer_menu to open the drawer. I put this code within my ToolbarFragment class:

snipet

As for the badge count, whenever you want to increment it I call this helper:

untitled

Here it is:

final

All 6 comments

@bhartsock that is independent of the MaterialDrawer the ActionBarDrawerToggle which can be managed by the Drawer doesn't allow you to do this. This will require a custom image for the toolbar, and then you will have to manually handle the open / close of the drawer.

Awesome,

I got it working. Thank you for your suggestion.

On Thu, Feb 4, 2016 at 11:19 AM, Mike Penz [email protected] wrote:

@bhartsock https://github.com/bhartsock that is independent of the
MaterialDrawer the ActionBarDrawerToggle which can be managed by the
Drawer doesn't allow you to do this. This will require a custom image for
the toolbar, and then you will have to manually handle the open / close of
the drawer.

—
Reply to this email directly or view it on GitHub
https://github.com/mikepenz/MaterialDrawer/issues/984#issuecomment-179926318
.

http://www.gemr.com/
Brian Hartsock | Android Developer
| _a._ 230 Commerce Way Ste 325 Portsmouth NH
| _m._ 603.531.0857
| _e._ [email protected]
| _w._ www.gemr.com
http://www.facebook.com/gemrsocial http://www.twitter.com/gemr
https://www.youtube.com/channel/UCuD4UbaSPjPV8sm78UdjF5A
http://www.instagram.com/gemrsocial
https://www.linkedin.com/company/5148026?trk=tyah&trkInfo=clickedVertical%3Acompany%2Cidx%3A2-1-6%2CtarId%3A1430418920434%2Ctas%3Agemr

@bhartsock great :). It would be great if you could add your solution here so others can find it.

To all those who are interested, this is what I did.

Make sure that you remove the .withToolbar() when creating the DrawerBuilder. This will have to be managed manually.

In your toolbar layout, add the following:

badge

Create this drawable to use as the background:

drawable

You will have to hook up a click listener to the nav_drawer_menu to open the drawer. I put this code within my ToolbarFragment class:

snipet

As for the badge count, whenever you want to increment it I call this helper:

untitled

Here it is:

final

@bhartsock awesome. thanks

@bhartsock please provide the complete code.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ghost picture ghost  Â·  3Comments

armoun picture armoun  Â·  3Comments

oleynikd picture oleynikd  Â·  4Comments

Ahmed-Emad picture Ahmed-Emad  Â·  4Comments

jd-alexander picture jd-alexander  Â·  4Comments