简体   繁体   English

通知图标显示在状态栏中,但不显示在通知本身中

[英]Notification icon showing up in status bar but not in notification itself

在此处输入图片说明

在此处输入图片说明


As you can see, the mipmap icon is showing in the status bar but not in the notification itself. 如您所见,mipmap图标显示在状态栏中,而不显示在通知本身中。 This is how I've set it: 这是我的设置方式:

Notification notification = new NotificationCompat.Builder(this).
                setSmallIcon(R.mipmap.ic_launcher). // This is the small icon
                // more code
                build();

Current test device is using Android 7.1.1 Can anyone help or explain why this is happening, or give some advice on how to fix it? 当前的测试设备使用的是Android 7.1.1,谁能帮助或解释这种情况的发生,或者提供一些解决方法? Thanks 谢谢

This is because Android requires a white icon in the notification bar. 这是因为Android要求通知栏中有一个白色图标。 So change it to a white icon. 因此将其更改为白色图标。

https://developer.android.com/guide/topics/ui/notifiers/notifications.html https://developer.android.com/guide/topics/ui/notifiers/notifications.html

What Android basically does, is painting your wall grey. Android基本上会做的是将您的墙漆成灰色。 Actually your wall is showing, but with a grey overlay. 实际上,您的墙正在显示,但带有灰色覆盖。

According to your question below, you can load your drawable and paint it to white like this: 根据下面的问题,您可以加载可绘制对象并将其绘制为白色,如下所示:

yourWallIcon.setColorFilter(Color.WHITE)

Note that yourWallIcon must be a drawable. 请注意, yourWallIcon必须是可绘制的。

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

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