Android Color Notification Icon

android notification icon size
android notification icon generator
how to set push notification icon in android
notification icon not showing android nougat
android notification icon guidelines
change notification background color android
change notification icon android
notification icon showing white android

I'm working on an app where I create a notification for the user. I want the icon to appear as white when it's in the status bar, but colored blue when it's being displayed in the drop down notification menu. Here's an example of the same thing being done by the Google Store app.

White notification in status bar:

Colored notification in drop down menu:

How can I replicate this? What properties do I have to set?

Edit: Here's my current code - I made the image all white with a transparent background, so it looks fine in the status bar, but in the notification drop, the image is still the same white color:

private NotificationCompat.Builder getNotificationBuilder() {
        return new NotificationCompat.Builder(mainActivity)
                .setDeleteIntent(deletedPendingIntent)
                .setContentIntent(startChatPendingIntent)
                .setAutoCancel(true)
                .setSmallIcon(R.drawable.skylight_notification)
                .setColor(ContextCompat.getColor(mainActivity, R.color.colorPrimary))
                .setContentTitle(mainActivity.getString(R.string.notification_title))
                .setContentText(mainActivity.getString(R.string.notification_prompt));
    }

I found the answer to my question here: https://stackoverflow.com/a/44950197/4394594

I don't know entirely what the problem was, but by putting the huge png that I was using for the icon into the this tool https://romannurik.github.io/AndroidAssetStudio/icons-notification.html#source.type=image&source.space.trim=1&source.space.pad=0&name=ic_skylight_notification and by placing the generated icons it gave into my mipmap folder, I was able to get the setColor(...) property to work correctly.

Change the Colour of my Notification! | by efe budak, When I was working on notifications on my sample android project, I realised that my notification icon does not have the colours that the original� Android 5.0+ enforces your icon to only be white and transparent however it still allows tinting on the notification shown in the shade, known as the "accent color". (The status bar icon color will still be unaffected). These may be adjusted in New Message or as defaults in your manifest.

For firebase nofitications sent from console you just need to add this in your manifest:

    <meta-data
        android:name="com.google.firebase.messaging.default_notification_icon"
        android:resource="@drawable/white_logo" />

    <meta-data
        android:name="com.google.firebase.messaging.default_notification_color"
        android:resource="@color/custom_color" />

Where white_logo is your app white logo, and custom_color is the color you want to have the icon and text colored.

More details here: https://firebase.google.com/docs/cloud-messaging/android/client

Android Notification Icons, Starting with Android 5, the OS forces Small Notification Icons to be all white when your own icons, you must make your icons the following size and colors: � 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. Let’s see how out icon looks like when we change its colour.

Here is what I did for my app ...

private void showNotification(Context context) {
    Log.d(MainActivity.APP_TAG, "Displaying Notification");
    Intent activityIntent = new Intent(context, MainActivity.class);
    PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, activityIntent, PendingIntent.FLAG_UPDATE_CURRENT);
    NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context);
    mBuilder.setSmallIcon(R.drawable.ic_notification);
    mBuilder.setColor(Color.GREEN);
    mBuilder.setContentIntent(pendingIntent);
    mBuilder.setContentTitle("EarthQuakeAlert");
    mBuilder.setContentText("It's been a while you have checked out earthquake data!");
    mBuilder.setDefaults(Notification.DEFAULT_SOUND);
    mBuilder.setAutoCancel(true);
    NotificationManager mNotificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
    mNotificationManager.notify(1, mBuilder.build());
}

Sample With Color:

Sample without Color:

Notifications Overview, In supported launchers on devices running Android 8.0 (API level 26) and higher, app icons indicate new notifications with a colored "badge"� Credits: As we already know that this is the old problem, actually this is not a problem. This is what we need to do a proper implementation. Why I’m writing this article is just because I have seen in many applications the push notification icon is showing the white icon when we run this in android 6.0 and greater versions.

When building the notification, you can set the color and the icon. If your icon is a pure white image, it'll apply the color for you in the correct spots.

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
    val manager = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
    val notificationId = 10 // Some unique id.

    // Creating a channel - required for O's notifications.
    val channel = NotificationChannel("my_channel_01",
            "Channel human readable title",
            NotificationManager.IMPORTANCE_DEFAULT)

    manager.createNotificationChannel(channel)

    // Building the notification.
    val builder = Notification.Builder(context, channel.id)
    builder.setContentTitle("Warning!")
    builder.setContentText("This is a bad notification!")
    builder.setSmallIcon(R.drawable.skull)
    builder.setColor(ContextCompat.getColor(context, R.color.colorPrimary))
    builder.setChannelId(channel.id)

    // Posting the notification.
    manager.notify(notificationId, builder.build())
}

Why? -- Android forcing removing of colors from the notification bar , I use Textra for messaging. The developer notified the users that Android is forcing developers to remove colors from the notification bar for icons. Butwhy? If you are running Android 6.0 or above, then you can Change Status Bar Icon Color, Theme and Style without using any Android App. To Set Custom Status Bar On Android, you can follow the below steps. Firstly, Open Notification Panel by sliding from the top of the screen.

If you want to change color and title name as per gmail and twitter in Push notification or inbuilt notification then you need to add these lines in notification.

 builder.setSmallIcon(R.drawable.skull)
    builder.setColor(ContextCompat.getColor(context, R.color.colorPrimary))

First line used for icon and in second line you need to define color

Setting Android Status Bar Background & Icon Colors, Here are a few tips and tricks to dynamically change the status bar color on your Android apps. Color. Add color to all the icons in your collection. 6 of 9 Edit mode. Enter the edit mode by clicking the pencil icon to edit the name and color of each icon separately. 7 of 9 Delete. Have you finished with this collection? Delete it and create a new one here. 8 of 9 Enjoy!

Android Notes 76 : How to customise notification icon and color , Firebase is a perfect tool for a lot of things and for notifications. It is the best :) We can override the default icon and color thanks to new Firebase� Not since Lollipop. Starting with Android 5.0, the guidelines say: Notification icons must be entirely white. Even if they're not, the system will only consider the alpha channel of your icon, rendering them white. Workaround

Customizing notifications, If you use a colored small icon, Android will display it as a white square: Small icon issue Google allows you to set an accent color for your push notifications. How to Change the Android Notification Icon/Status Bar Icon for Push-notification in #flutter? Ask Question Asked 2 years, 4 months ago. Active 5 months ago.

Change icon color from white in notification bar?, Can someone tell me how to change the icon colors in the notification bar on the One? I can't find it anywhere and my background is very light� Set the small icon to use in the notification layouts. NotificationCompat.Builder: setSmallIcon(int icon) Set the small icon to use in the notification layouts. NotificationCompat.Builder: setSortKey(String sortKey) Set a sort key that orders this notification among other notifications from the same package. NotificationCompat.Builder

Comments
  • I was able to solve this problem - please see my answer below.
  • THANK YOU! I spent way too long trying to figure out why my notification icon was still appearing white in the notification banner, and finally with that tool my notification icon correctly uses the color in the banner (while still being white in the status bar)
  • To everyone who ended up here and is genering icons with photoshop (or any other graphic design tool). Don't use CMYK mode! Use RGB when creating/exporting an icon - it helped in my case
  • Added the icon as suggested by the "Oblivionkey3" but after adding <meta-data android:name="com.google.firebase.messaging.default_notification_color" android:resource="@color/custom_color" /> icon color set to custom. Before this icon color was grey on Andriod Oreo notification (Status bar was icon being displayed in white).
  • what is custom_color ? and how to set it?
  • See also: github.com/firebase/quickstart-android/tree/master/…
  • @mukesh.kumar, custom_color is any color you want to use. you just need to declare it in colors file
  • Unfortunately all that changing the color did for me was change the color of the text next to the image in the notification drop down, not change the color of the image at all.
  • Are you using a pure white icon as your small icon? It should colour that when it needs to.
  • It's pure white with a transparent background, and it's saved as a png
  • I edited my post, and tested some code on O, and the code above works for making my icon and text both my color_primary when pulled down, and just pure white when not. Hopefully that'll help more.
  • I appreciate your help, but I managed to find solve this using another method which I just added to this page.
  • I'd advise against this or else you'll have a coloured icon within the status bar.