Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5848685
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T12:53:38+00:00 2026-05-22T12:53:38+00:00

Here is my unanswered question: Add new item count to icon on button –

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T12:53:39+00:00Added an answer on May 22, 2026 at 12:53 pm

    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:

    import android.content.Context;
    import android.graphics.Canvas;
    import android.graphics.Paint;
    import android.util.AttributeSet;
    import android.widget.Button;
    
        public class CounterButton extends Button{
            protected int count=0;
            protected final Paint myTextPaint = new Paint();
            protected final Paint myCirclePaint = new Paint();
    
            public CounterButton(Context context, AttributeSet attrs) {
                super(context, attrs);
                this.setBackgroundDrawable(getResources().getDrawable(android.R.drawable.ic_dialog_email));
                this.myCirclePaint.setARGB(150, 255, 0, 0);
                this.myTextPaint.setARGB(150, 255, 255, 255);
    
            }
    
            @Override
            protected void onDraw(Canvas canvas) {
                        if(count!=0){
                canvas.drawCircle((float) (this.getWidth()*.75), (float) (this.getHeight()*.4), this.getHeight()/5, myCirclePaint);
                canvas.drawText(Integer.toString(count), (float) (this.getWidth()*.75), (float) (this.getHeight()*.4), this.myTextPaint);
                 }
            }
        }
    

    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:

    CounterButton cb=(CounterButton) findViewById(R.id.whateverYouGaveItInXML);
    cb.count=SomeNewNumber;
    cb.invalidate;
    

    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.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here's some sample HTML <style> .icon {display:none;} </style> <ul> <li>ABC <i id=abc class=icon>x</i></li> <li>DEF
Need to generate courses list and count all unanswered answered but unchecked Questions. Here's
There is a related unanswered question here: c++ - Variables auto-initialized to 0 in
and thank you. This question is very similar to this old, unanswered question here:
I asked a still unanswered question that will shed more light on this question.
Question is similar to this (unanswered) and this one (same problem not involving Git).
After reading alot about VTables, I still have one unanswered question. Given the next
Update: Since this is unanswered, I'm changing the question slightly. Comments on the post
This is a bit esoteric and it's possible this question will go unanswered until
I have asked this question in many sites and my question remain unanswered. Some

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.