6
  1. I am working on Android app (API level >23). And I have to support Notification.
  2. And my notification icon is supported more than two colors.
  3. If I use that icon then icon displays in grey in notification pannel.
  4. So I have created background transparent and completly white icon and set color dynamically.

  5. But I am able to set only one color (setColor()).

So my question is :-

How to support multiple colors (more than two color or color gradients) for Android Notification icon? Note :- I have taken reference of Android Push Notifications: Icon not displaying in notification, white square shown instead

Thanks for support in advance.

2 Answers 2

8

If your app targets SDK 21+ the system will always tint your notification icon

  • white when it's displayed in a dark status bar
  • dark grey when it's displayed on a light status bar (API 23+)
  • dark grey when it's collapsed at the bottom of the notification shade
  • the color you set when it's part of a notification in the notification shade (API 24+, before that you'd have a white icon over a colored circle as the default large notification icon)

You have no control over the color other than what's described above.

But you can work with alpha channel. You can achieve different degrees of white/dark grey/color in your icon.

No, there's no other way. Pass this on to your designer and management.

Android 5.0 Behavior Changes

Notifications

Material design style

  • Update or remove assets that involve color. The system ignores all non-alpha channels in action icons and in the main notification icon. You should assume that these icons will be alpha-only. The system draws notification icons in white and action icons in dark gray.

Source: https://developer.android.com/about/versions/android-5.0-changes.html#NotificationsMaterialDesignStyle

Sign up to request clarification or add additional context in comments.

5 Comments

@AlokMishra You referenced another question, that question has an accepted answer and in that answer is a link to official Google documentation. Me having to link to the same thing again does not make it any more valid. The rules are set, it really is official, deal with it. Here's the link, for convenience: developer.android.com/about/versions/…
Thank you for your answer :) finally design n product team agree with your solution.
@EugenPechanec but some apps are able to set notification icon with different color. For Example dominos.. If its not possible, then how they can achieve it?Because I am also want to set notification icon with different colors
Send a link, there's a million dominos. Only apps that target at most SDK 19 will have colored notification icons. Those apps also will not be admitted to Play store, which requires target SDK somewhere around 28.
@EugenPechanec stackoverflow.com/q/62422988/11630822 this is my stack question..here I have added screenshot of dominos taken in my android phone(pie version)
-1

Notifications

Make sure your notifications take these Android 5.0 changes into account. To learn more about designing your notifications for Android 5.0 and higher, see the notifications design guide.

Material design style

Notifications are drawn with dark text atop white (or very light) backgrounds to match the new material design widgets. Make sure that all your notifications look right with the new color scheme. If your notifications look wrong, fix them:

  • Use setColor() to set an accent color in a circle behind your icon image.
  • Update or remove assets that involve color. The system ignores all non-alpha channels in action icons and in the main notification icon. You should assume that these icons will be alpha-only. The system draws notification icons in white and action icons in dark gray.

from: https://developer.android.com/about/versions/android-5.0-changes.html#NotificationsMaterialDesignStyle

5 Comments

This is pre requirement of notification but how to set multiple colors and that's what OP asked ?
when you're building your notification, the Notification.Builder contains method to set icon
my question is how to set multiple colors in notification icon not about basic setup for notification or setIcon()
if you have multiple icons with different colors you can easily create a method to return the good icon variant for a notification type when set icon to notification? builder.setSmallIcon(getGoodColorIcon())
Can you please create any sample with more than 2 colors in notification icon which will work in Android-O ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.