Java 在通知图标中添加小图标
我使用下面的代码来获取通知图标。这会给出正常的通知图标,但右下角有一个白色的小框。我如何设置图标也Java 在通知图标中添加小图标,java,android,notifications,notification-icons,Java,Android,Notifications,Notification Icons,我使用下面的代码来获取通知图标。这会给出正常的通知图标,但右下角有一个白色的小框。我如何设置图标也 public void not() { Notification noti = new Notification.Builder(context).setSmallIcon(R.mipmap.lnc) .setLargeIcon(BitmapFactory.decodeResource(context.getResources(), R.mipma
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);
}
从棒棒糖开始,您的小图标必须是单色的,即透明背景和白色,否则将显示为白色框。因此,将你的R.mipmap.lnc转换成一个轮廓,也就是说,创建你的图标时,你想要显示的部分应该是白色的,背景应该是透明的。如果要向背景添加颜色,可以使用setColor方法
阅读链接。从棒棒糖开始,您的小图标必须是单色的,即透明背景和白色,否则它将显示为白色框。因此,将你的R.mipmap.lnc转换成一个轮廓,也就是说,创建你的图标时,你想要显示的部分应该是白色的,背景应该是透明的。如果要向背景添加颜色,可以使用setColor方法 阅读链接。使用
setSmallIcon(R.drawable.YOUR_SMALL_ICON
)设置通知的小图标
仅供参考,根据设计指南,您必须为Builder.setSmallIcon()
使用轮廓。看
使用setSmallIcon(R.drawable.YOUR_SMALL_图标
)设置通知的小图标
仅供参考,根据设计指南,您必须为Builder.setSmallIcon()
使用轮廓。看
试试这个
试试这个这样我就有了一个主图标,然后它在右下角有一个圆圈,里面有一个白色的小框。Setcolor将圆形的颜色从默认的灰色设置为所选的颜色,尽管白色框保持白色。然后将不会有任何白色框,将有一个背景颜色设置的圆形&里面将是您创建的白色图标。是的,实际上我使用的是mipmap图标而不是drawable。现在我可以看到我的小图标了,我看到了一个主图标,然后在右下角有一个圆圈,里面有一个白色的小盒子。Setcolor将圆形的颜色从默认的灰色设置为所选的颜色,尽管白色框保持白色。然后将不会有任何白色框,将有一个背景颜色设置的圆形&里面将是您创建的白色图标。是的,实际上我使用的是mipmap图标而不是drawable。现在我可以看到我的小图标了。
Notification noti = new Notification.Builder(context)
.setSmallIcon(getNotificationSmallIcon())
.setLargeIcon(BitmapFactory.decodeResource(context.getResources(), R.mipmap.lnc))
.setContentTitle("My Title")
.setContentText("Done")
.build();
..................
..........................
private int getNotificationSmallIcon() {
boolean useWhiteIcon = (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP);
return useWhiteIcon ? R.drawable.ic_silhouette : R.drawable.ic_launcher;
}
NotificationCompat.Builder mNotifyBuilder;
mNotifyBuilder = new NotificationCompat.Builder(context)
.setContentTitle("Captian Mansoura")
.setContentText("Busy , On trip Now")
.setLargeIcon(BitmapFactory.decodeResource(context.getResources(), R.mipmap.lnc))
.setSmallIcon(R.mipmap.notify_offline);