This question already has an answer here:
I would like to make a notification icon in the action bar to inside the number of notifications.
For example (Google Adsence) :
I found this answer on stackoverflow, but it does not fully answer my question because in this case it is only the number and not an icon with a number: Actionbar notification icon with count
After a lot of trying of nearly all resources on SO I turned to blogs; successfully. I want to share what worked for me (Api >= 13).
Let's start with the way it's used in code:
The
menu_my.xml
:This class that conveniently makes a
BadgeDrawable
:This class that helps to set the number.
And mui importante a drawable (like a layout) in
res/drawable
:Good luck!