Here is my unanswered question:
Add new item count to icon on button – Android
Basically I want to display “new” counts on top. I see it as overlaying some view over existing button. How this can be done?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Ok here is what i’d do:
Create a custom control that extends button. I’m not going to do the pretty graphics for you but this will give you the basic idea:
Clean up the sizing of your text you draw, the circle positioning (and add a border etc) and you have a custom control. You could further extend it so you could set the background in xml or dynamically and you have a reusable control with a number counter in a circle.
then in your code you could do:
the invalidate will redraw the image with the new value in the circle.
I used a button in the event you want to have it clickable easily and all that – but you could just as easily extend view if you are just doing a view.