I want to create notification like here:
Red circle = icon which is always visible. Blue circle = icon that is visible only when you expand.
How do I make such a red circle notification?
must I create 100 images or can I use custom notification like text? Can i join two images together?
I found this:
http://www.framentos.com/en/android-tutorial/2012/02/20/how-to-create-a-custom-notification-on-android/
Custom notification layouts and text colors
But I still don't know how to create this red circle. With this i know how to create blue circle but this I don't need. I am not creating battery!
Any ideas?
The only text that you can put in the notification area/status bar ("red circle") is ticker text, which disappears after it's displayed (setTicker). The purpose of that area is to remind users that a notification is outstanding, using the small icon (setSmallIcon). You could make 100 different icons, one for each percentage, but then you would not be using Android's standard design guidelines for notifications.
I suggest that if you want a battery indicator, use 5 battery icons. One icon would be a "full" battery, along with 1 each for 75%, 50%, 25%, and "very low" (in red). I suspect that most users don't need to see exactly how much battery they have left in the status bar. You can then show the exact numbers and estimated time remaining in the full notification.
Related
In android notification, it's seam their is 3 different icons (see the picture below). I know how to set the large icon (via setlargeicon), however i don't know how to set the both 2 small icons as their is only one procedure setSmallIcon available.
It is the same setSmallIcon for both locations. However, you can also use setColor() to set the background color on the notification - that is how the lower icon gets the blue background.
So I've been working with Android Notifications and after setting a large image, I found out that my small image is actually not displaying properly.
As you can see on the following screenshot of the lockscreen, the background of the small icon is transparent. I want to set a specific colour there, just like the one Outlook.com is using:
Another example where the small icon shows next to the large one (please take notice of the small icon which is actually displaying, but not really noticable because there is just no background):
I've been thinking about changing the small icon to include the background colour, but obviously the colour would also be shown in the statusbar and that's wrong.
Try setColor() with NotificationCompat.Builder to set the accent color, which should be used by the colored circle behind the icon.
I would like a to place persistent text in the notification area that updates once every second. setTicker() in the NotificationCompat.Builder class will not work, because it hides everything else in the notification area. I am only looking to place text there that is a few characters long, taking up only a small piece of the notification area.
One way I think this can be done is by calling setSmallIcon(), and somehow using this small icon area to display text. I took a screenshot of an app's notification that I believe to be using this strategy. Notice the 165 KB/s:
You shouldn't use the ticker text of the notification to update the user. This text is shown when the notification is posted.
Like the screenshot it uses setSmallIcon like you mentioned.
You can create a bitmap and draw text on with the canvas API, then updating your current ongoing notification
Example how to draw text on bitmap
This will change the icon in the statusbar and visible for the user.
Is it possible to overlay a notification icon with some text/int? or is it possible to generate a custom icon on the fly?
For example I have the current icon displayed for my notification, I would like to be able to display for example the number 2 within the red box.
As this is not a count of notifications ( so not the red bubble ), the setting the "number" in the notification will not work.
Will I have to just create an individual icon for every possible number I wish to display? Or is there a better way of achieving this?
Try using AnimationDrawable's. You can use them to combine multiple drawables into a single one, and select the one you want to display. I really think, this is the way to go.
More info: AnimationDrawable
Off course, you will have to provide individual drawables for all your Integers you want to display, but this way, you can easily change the appearance of your notifications
Notification.Builder
Has two methods:
setLargeIcon(Bitmap icon)
and
setSmallIcon(int icon)
Since the small Icon only seems to take a resource ID I think you'd have to provide a drawable resource for every possible number you want then you could select which one to use at run time.
The Large icon however takes a Bitmap, so you should be able to generate one with some java code and pass it in.
Truthfully though I don't exactly know what the difference is between the Large and Small icons. I don't have much experiences with Notifications in general. You might luck out and find that setLargeIcon will work for what you need. But it might also be that you can only use a Bitmap object for the image that is shown when the notification bar is pulled down, not the one that is shown while it is collapsed.
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