简体   繁体   English

Android推送通知系统任务栏图标为灰色

[英]Android Push Notification System Tray Icon Is Gray

I'm doing push notifications for Android using Firebase Cloud Messaging, and everything is going well, but I'm wondering what's going on with the icon color in the system tray. 我正在使用Firebase Cloud Messaging为Android做推送通知,一切都进行得很好,但是我想知道系统托盘中图标的颜色是怎么回事。 It is being turned into a greyscale image instead of keeping its original color. 它正在被转换为灰度图像,而不是保留其原始颜色。 I am able to colorize it with the setColor method, but I'd like the icon to not lose its color at all, is this possible? 我可以使用setColor方法为它着色,但是我希望图标完全不丢失其颜色,这可能吗? I have tried using a variety of different images with their own sizes, transparent/non-transparent, white background etc., based on some posts I could find. 根据我能找到的一些帖子,我尝试使用各种不同的图像,这些图像具有自己的大小,透明/不透明,白色背景等。 I could not seem to locate an answer on what is actually happening here. 我似乎无法找到有关此处实际发生情况的答案。 My compile/target sdk is 26 at the moment. 我的编译/目标SDK现在是26。 I'm using Android 8.0 and 9.0 on emulators (Nexus 6), and 8.1 on a physical device. 我在模拟器(Nexus 6)上使用Android 8.0和9.0,在物理设备上使用8.1。

.setSmallIcon(R.drawable.app_logo)
.setColor(Color.GREEN)

通知栏图标颜色为灰色

It is a bit misleading in case of notification's small icon. 通知的小图标有点误导。 If you'll use colored drawable - it will appear tinted in a color, that Android OS choses to use. 如果您将使用彩色的可绘制对象-它会以某种颜色显示,这是Android OS选择使用的颜色。 That is the way it is. 就是这样。 If you'll provide .setColor() attribute - it will use that as a tint. 如果您提供.setColor()属性-它将用作色彩。 It's because small icon is for notification tray (and can be either white or black) and will be used also with app name in notification when you'll pull notification tray downwards. 这是因为小图标用于通知托盘(可以是白色或黑色),当您将通知托盘向下拉时,也会与通知中的应用程序名称一起使用。 Sometimes it will be not tinted in notification tray on some devices made of chineezium (as my Xioami device does). 有时,它不会在某些由Chineezium制成的设备的通知托盘中着色(就像我的Xioami设备一样)。 Just give it to Google and commit to rules that Google made us to follow 只需将其交给Google并遵守Google让我们遵循的规则

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM