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 4259974
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T05:51:28+00:00 2026-05-21T05:51:28+00:00

In iOS we have a feature to update the app icon with the new

  • 0

In iOS we have a feature to update the app icon with the new pending messages for the user by showing a small number on the right-top corner of the icon and similarly I would like to know if we have method to update a ImageView/ImageButton in android(Here I am not looking to update the icon on the home screen but inside my app).

For example, the pic shows the red background icon with the number of messages pending to be read in red and if there are no messages it shows with a gray background.

enter image description here

Thanks,

  • 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-21T05:51:29+00:00Added an answer on May 21, 2026 at 5:51 am

    I was interested in this SO as I didnt know how to do it neither. So I started looking into it and here is how I did it.

    • I am not a specialist in UI so there may be some stuff useless/wrong in the following XML.
    • From what I said above, I didnt manage to have the count on the bottom right corner of the icon. 🙂
    • For test, I use the standard icon.png from the sdk

    res/drawable/shapecount.xml

    <?xml version="1.0" encoding="utf-8"?>
    <shape
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:shape="rectangle">
      <corners android:radius="20dp"  />    
      <solid android:color="#ff2233" />
    </shape>
    

    res/layout/my_widget_layout.xml

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout  xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content">
    
    <RelativeLayout
        android:orientation="vertical"
        android:background="@null"
        android:id="@+id/rlayout"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" >
        <ImageView 
                android:id="@+id/icon"
                android:src="@drawable/icon" 
                android:layout_margin="0dp"
                android:layout_height="wrap_content" 
                android:layout_width="wrap_content"/>
    
        <TextView android:layout_width="wrap_content" android:layout_height="wrap_content"
            android:text="50" android:textSize="9dp" android:textStyle="bold"  
            android:background="@drawable/shapecount"
            android:textColor="#FFFFFF"
            android:paddingLeft="3dp" android:paddingRight="3dp"
                android:layout_margin="0dp"
            android:layout_alignBottom="@+id/rlayout"
            android:id="@+id/txtCount" />
    
    </RelativeLayout>
    
    <TextView android:layout_width="wrap_content" android:layout_height="wrap_content"
        android:text="My App Name" android:textSize="9dp" android:textStyle="bold"  
        android:background="@drawable/shapecount"
        android:textColor="#FFFFFF"
        android:paddingLeft="3dp" android:paddingRight="3dp"
            android:layout_margin="0dp"
        android:layout_alignBottom="@+id/rlayout"
        android:id="@+id/txtAppName" />
     </LinearLayout>
    

    An home widget is actually a normal view that you can build in an XML file like you would for an activity. There is some rules to follow though. See this link for guideline

    In this link which shows you how to build an AppWidget, you can see the following code:

    // Get the layout for the App Widget and attach an on-click listener to the button
      RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.appwidget_provider_layout);
    

    where R.layout.appwidget_provider_layout is the layout of your home widget, which will be my_widget_layout.xml

    From that views, you can set the value you want for any count text view:

    int count = 50;//Or whatever value you set to it.
    views.setTextViewText(R.id.txtCount,Integer.toString(count));
    

    and then you just have to update the widget itself:

    appWidgetManager.updateAppWidget(appWidgetId, views);
    

    NOTE:

    The updatePeriodMillis doesnt allow the widget to request an update more than once every 30 min so I use a combination of BroadcastReceiver and Service

    EDIT:

    See below a activity test if the count you want should be within an Activity instead of a AppWidget. It uses the same XMLs as above:

    public class TestActivity extends Activity {
        /** Called when the activity is first created. */
    
        final Random gen = new Random();
    
    
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);
    
            final TextView t = (TextView) findViewById(R.id.txtCount);
    
            Timer timer = new Timer();
            timer.schedule(new TimerTask() {
    
                @Override
                public void run() { 
                    runOnUiThread(new Runnable() {
    
                        @Override
                        public void run() {
                            int a = gen.nextInt(20);
                            t.setText(Integer.toString(a));                     
                        }
                    });
                    }
                }
            ,new Date(), 3000L);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my iOS app, I have a simple feature that lets the user rate
I have an iOS app that uses a number of enums for valid values,
I created an app using the iOS 5 Storyboard feature, and have decided I
i have made an application with storyboard and the new iOS 5 feature like
I have a issue to make a facebook sign-up feature in ios app. I
Does Android have feature similar to iOS where it display red Badge bubble icon
I want to have a feature of Recent 20 Items in my iOS app.
Overall my app works on all iOS device however I have a feature that
I could have sworn this was a new feature in iOS 5, but I
I am a making a small iOS web app with a chat feature. The

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.