解决5.0以上通知栏图标变白
2016-02-15 14:39
495 查看
5.0以上,系统会自动将通知栏图标全部填充为白色,解决方法如下:
创建资源drawable和drawable-v21
1.drawable中放入和启动图标相同,名为ic_notification的图片
如:
2.drawable-v21中放入规矩形状的图片,命名为ic_notification
如:
简单来说就是把背景图层去掉
那么5.0以下会使用和启动图标相同的通知栏图标,5.0以上会使用简单的白色规矩图标,两种不同的图标
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);
创建资源drawable和drawable-v21
1.drawable中放入和启动图标相同,名为ic_notification的图片
如:
2.drawable-v21中放入规矩形状的图片,命名为ic_notification
如:
简单来说就是把背景图层去掉
那么5.0以下会使用和启动图标相同的通知栏图标,5.0以上会使用简单的白色规矩图标,两种不同的图标
相关文章推荐
- CInt
- 重拾c语言——宏定义的预处理
- OpenCV学习04
- Android中使用TextView实现图文混排的方法
- 网站开发环境的配置
- EFI基本概念之FV
- android 自定义下拉刷新动画效果
- OpenCV学习03
- Extjs 删除输入内容前后空格
- 如何入门 Python 爬虫?
- ehcache的简单使用
- android首页Splash页面简单实现
- 让身体这个硬件今年也来个升级
- 共享系统(pydio)
- 新手学习CSS的一些些笔记
- 五子棋AI算法第三篇-Alpha Beta剪枝
- OpenCV学习02
- git submodule常用的几个命令
- C/C++语言复习二
- 算法之美_源代码发布(6)