我正在使用下面的代码来获取通知图标。这会提供正常的通知图标,但右下角有一个小白框。我怎样才能为其设置图标。
public void not() {
Notification noti = new Notification.Builder(context).setSmallIcon(R.mipmap.lnc)
.setLargeIcon(BitmapFactory.decodeResource(context.getResources(), R.mipmap.lnc))
.setContentTitle("My Title")
.setContentText("Done").setSmallIcon(R.mipmap.lnc)
.build();
NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
// hide the notification after its selected
noti.flags |= Notification.FLAG_AUTO_CANCEL;
notificationManager.notify(0, noti);
}
最佳答案
从Lollipop开始,你的小图标必须是单色的,即透明背景和白色,否则它将显示为白框。因此,将您的 R.mipmap.lnc 转换为剪影,即以这样的方式创建您的图标:您想要显示的部分应该是白色的,背景是透明的。如果您想向背景添加颜色,可以使用 setColor 方法来完成。
阅读this链接。
关于java - 在通知图标中添加小图标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43187550/