在状态栏中将文本显示为图标
我知道有人问过这个问题,但还没有答案。有几个应用程序会同时显示图标和数字(例如,如果 Android 下载的更新数量超出了状态栏所能容纳的数量,则会出现一个下载图标,其中有一个小数字代表将显示更多图标的数量)。其他应用程序显示百分比值或温度。有人建议这些应用程序只需有 N 个图标(因此,如果温度从 50C 到 75C,代码中将包含 26 个图像(各种格式)。更糟糕的是,如果还需要 70F - 105F ,图像的数量会非常大,
我想做的只是提供可以用某种颜色绘制的文本(即 75F 为绿色,但 99F 为红色),或更改背景颜色,等等。是否有任何方法可以做到这一点,而不必创建 25 个以上的图像来表示每个值?请注意,我想要状态栏中的数字,而不是当您单击
API 图标 时的自定义视图。是作为整数传递给通知类的资源,这似乎是动态创建该图标并将其填充到资源中的唯一方法。
注意:我 可以吗?已经研究过使用通知的 .number 字段虽然这给了我一个图标上的数字,但这并不是我真正想要的,并且不允许我进行干净的实现(而且数字非常小)。
提前致谢。
马蒂
I know that this questions has been asked, but there have been no answers. There are several apps that display both an Icon and a number with it (for example, if Android downloads more updates than will fit on the status bar, there is a download icon with a small number representing how many more icons would be displayed). Other apps display a % value or temperature. It was suggested that these apps simply have N icons (so, if temperature runs from 50C to 75C there would be 26 images (of various formats) that would be included with the code. What is worse is that if 70F - 105F were also required, the number of images would be very large.
What I would like to do is simply provide text that I could draw in a certain 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? Note that I WANT the number in the status bar, not as a custom view when you click on the notification.
From the API, the icon is a resource that is passed to the Notification class as an integer. It would seem the only way to make this work is to dynamically create that icon and stuff it in the resources. Is this, or any other method, possible?
Note: I have looked at using the .number field of the Notification class. Although this gives me a number over the icon, it is not really what I am looking for, and, does not allow me to do a clean implementation (plus the number is really tiny).
Thanks in advance.
Marty
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论