Android Notification Has a Color Icon Instead of Being Turned White

Android notification has a color icon instead of being turned white

As suggested by Will Jones, the solution was to use a SVG file and convert it to XML using this: http://inloop.github.io/svg2android/. I then copied the file to android/app/src/main/res/drawable/notification_icon.xml and deleted the old PNG file.

The icon now renders properly.

android notification icon showing as white block

I have found the solution!

I only found hints on what the requirements are for a Android Notification (SDK 22 / Version 5.1.1)but after searching for over 4 hours, finally a complete and working solution for this.

Here are the steps I followed and it seems to be inline with what is mentioned on various forums, questions/answers and doc, but no "steps/requirements" of what is needed:

Creating and preparing your image

  1. Create your image, however you want, take your app icon if you like:
    Sample Image
    Quick and dirty
  2. Download an application to set transparency - I used IrfanView, it works well
    Sample Image
    Here is my image in IrfanView
  3. Open your image in IrfanView, click File > Save As or press 's'
  4. You should have a Save Dialog open (and a save options dialog, top right - if not, right at the bottom of the save dialog, select the Save options dialog checkbox, and it should open)

  5. My settings (which were given by default) are:

    • Compression level - 6
    • Use main window color for transparency - Checked
    • Binary Encoding
    • (ICO): Use main window color for transparency - Checked
  6. Check the following 2 boxes:

    • Save Transparent Color - Checked (I tried with only this checked, it didn't work - someone can extend on why not)
    • Save Transparentcy as Alpha Channel - Checked
  7. Save as PNG file.
    Sample Image
    Save Box with Save Options

In Android Studio:

  1. Right-Click Drawable folder > Add image asset (any resource folder should do)
    Sample Image
  2. Click on Notification Icon from the top drop-down list (default is Launcher Icon)
    Sample Image
  3. Select Image > Browse to image> click ok
    Sample Image
    You will notice your image is greyscale

this is normal since the Lollipop SDK (API 21 - Ver 5.0.1) only allows this type of color scheme, in searching I came across the materials design page which mentioned something in this line (Someone can extend on why this is)

Below, you will notice your notification icon in different 'dpi resolutions', adding a image normally will show a white block, but adding transparency solves this.

I believe one can use this from a 'colorful' perspective, in this case, IrfanView has a default background of black, this creating a "inverted" image in respect to this color (assuming in IrfanView, one leaves the "Use main windows color for transparency - checked" ) you can create different and interesting images.

I really hope this helps!

SmallIcon Color Turn To White Automatically Why In Notification Android?

.setSmallIcon(android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP ? R.mipmap.ic_launcher : R.drawable.notification_icon_bw_xhdpi)
.setColor(ResourcesCompat.getColor(getResources(), R.color.primary, getTheme()))

Use color to distinguish your app from others. Notification icons should only be a white-on-transparent background image. (https://developer.android.com/design/patterns/notifications.html)

Before Android Lollipop you can use same mipmap icon for all notification icon. But from Lollipop onwards you need to create new notification icon (Silhoette kind of icon).

Android notification icon is a white circle

It seems to be a problem of cache during compilation ... The first image I was using was bad (fully colored), so I think my compilator created somekind of cache on the filename.

I work on Windows and did this : uninstall the app from my phone, invalidate all cache from Android sudio => at re-compilation, the icon was OK.

Do drawer notification icons have to be white?

Yes, icon should be white, You have to create an icon with white and transparent feature and set the deserved background color

NotificationCompat.Builder b = new NotificationCompat.Builder(ctx,Const.NOTIFICATION_CHANNEL);

b.setAutoCancel(true)

.setDefaults(Notification.DEFAULT_ALL)
.setWhen(System.currentTimeMillis())
.setBadgeIconType(R.drawable.logo)
.setLargeIcon(BitmapFactory.decodeResource(ctx.getResources(),R.drawable.logo))
.setContentTitle(title)
.setContentText(message)
.setDefaults(Notification.DEFAULT_LIGHTS | Notification.DEFAULT_SOUND)
.setContentIntent(contentIntent);
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
b.setSmallIcon(R.drawable.new_logo);
b.setColor(ctx.getResources().getColor(R.color.green));

} else {
b.setSmallIcon(R.drawable.logo);
}

Here logo is coloured icon and new_logo is white icon

Notification icon turns white in Marshmallow

As per the Android 5.0 behavior changes:

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.

You can use setColor() to change the background color visible on the notification, but the small icon will always only be alpha-only i.e., colored a single color by the system.

Android notification icon colour sometimes white, sometimes colourful

Well, I think the problem was something different. My code for creation the notification is only called, when the app is open on screen. When I receive a notification and the app is closed, the notification is handled by the Android system automaticly.

I had to set the color in the notification, which is send to the FCM Server:

 $data = [
'notification' => [
'title' => 'Warnung: Wohnzimmer',
'text' => 'Innen: 20,3°C Außen: 24,5°C, Tendenz: -0,2°C',
'color' => '#83c3ed',
'sound' => 'default'
],
'to' => '/topics/testNotification'
];

Now I get a lightblue background icon within the app and also when the app is closed.

Notification icon on Android shown as a white square

I think you generated the icons of wrong size.
I re-generated them using the android asset studio and seems to be working at my end.
You can download then using this link:

https://romannurik.github.io/AndroidAssetStudio/icons-notification.html#source.type=text&source.text.text=capenergy&source.space.trim=1&source.space.pad=0&name=ic_stat_capenergy



Related Topics



Leave a reply



Submit