为什么在Android Lollipop中用Notification.Builder.setSmallIcon设置的图标显示为白色方块? [英] Why do icons set with Notification.Builder.setSmallIcon in Android Lollipop show as a white square?

查看:496
本文介绍了为什么在Android Lollipop中用Notification.Builder.setSmallIcon设置的图标显示为白色方块?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有此代码:

Notification notif;

// Build notification
Notification.Builder notifBuilder = new Notification.Builder(context);
notifBuilder.setContentIntent(pendingIntent);
notifBuilder.setContentTitle(title);
notifBuilder.setSmallIcon(icon_resId);
notifBuilder.setContentText(ne.getCaption());
notifBuilder.setDefaults(Notification.DEFAULT_ALL);
notifBuilder.setAutoCancel(autocancel);
notifBuilder.setWhen(System.currentTimeMillis());
notif = notifBuilder.build();

,并且在Android 4.4中正常工作.

and works fine in Android 4.4.

但是,在Android 5.0中,状态栏中显示的图标是一个白色正方形.锁定设备后出现的新通知正文"中显示的图标是正确的.

However, in Android 5.0 the icon showed in status bar is a white square. The icon showed in the new "notification body", that appears when device is locked, is correct.

http://developer.android.com/reference/android/app/Notification中. Builder.html ,我在API级别21中没有看到有关通知图标的新内容

In http://developer.android.com/reference/android/app/Notification.Builder.html, I don't see anything new about notification icons in API Level 21

推荐答案

我解决了将图标大小更改为16x16 px并仅使用白色的问题

I have resolved changing the icon size to 16x16 px and using only white color

这篇关于为什么在Android Lollipop中用Notification.Builder.setSmallIcon设置的图标显示为白色方块?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆