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.

Thanks,
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.
icon.pngfrom the sdkres/drawable/shapecount.xml
res/layout/my_widget_layout.xml
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:
where
R.layout.appwidget_provider_layoutis the layout of your home widget, which will bemy_widget_layout.xmlFrom that
views, you can set the value you want for any count text view:and then you just have to update the widget itself:
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
Activityinstead of aAppWidget. It uses the same XMLs as above: