Display text as an icon in the status bar

I know that these questions were asked, but there were no answers. There are several applications that display both the icon and the number with it (for example, if Android downloads more updates than it will be placed in the status bar, there is a download icon with a small amount that displays how many more icons will be displayed). In other applications,% or temperature is displayed. It has been suggested that in these applications there are only N icons (therefore, if the temperature is between 50 and 75 degrees, 26 images (of various formats) will be added that will be included in the code. Worse, if 70F - 105F is also required, the number of images will be very large.

What I would like to do is simply provide text that I could draw in a specific color (i.e. 75F in green, but 99F in red) or change the background color, etc. Is there any way to do this without having to create 25+ images to represent each value? Please note that I WANT the number in the status bar, and not as a custom view when I click on the notification.

From the API, an icon is a resource that is passed to the Notification class as an integer. It would seem that the only way to do this work is to dynamically create this icon and use it in resources. Is this possible or some other method?

Note. I examined the use of the .number field of the Notification class. Although this gives me a number above the icon, this is not exactly what I am looking for, and does not allow me to perform a clean implementation (plus the number is really small).

Thanks in advance.

Marty

+6
source share

Source: https://habr.com/ru/post/903432/


All Articles