5.0以上,系统会自动将通知栏图标所有填充为白色,解决方法以下:ui
final NotificationManager mNotificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);//TODO //FLAG_UPDATE_CURRENT:若是构建的PendingIntent已经存在,则替换它,经常使用 final PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);final Notification notification = new NotificationCompat.Builder(context) .setContentTitle(title) .setSmallIcon(R.drawable.ic_notification) .setContentText(content) .setDefaults(Notification.DEFAULT_ALL)//铃声、闪光、震动均系统默认。 .setContentIntent(pendingIntent) .setAutoCancel(true)//设置这个标志当用户单击面板就能够让通知将自动取消 .build();mNotificationManager.notify(notificationId, notification);1234567891011121314
建立资源drawable和drawable-v21
1.drawable中放入和启动图标相同,名为ic_notification的图片
如:
2.drawable-v21中放入规矩形状的图片,命名为ic_notification
如: spa
简单来讲就是把背景图层去掉
那么5.0如下会使用和启动图标相同的通知栏图标,5.0以上会使用简单的白色规矩图标,两种不一样的图标code