博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Android 那些年踩过的坑
阅读量:6647 次
发布时间:2019-06-25

本文共 1620 字,大约阅读时间需要 5 分钟。

1. Notification bar icon turns white in Android 5 Lollipop

http://stackoverflow.com/questions/28387602/notification-bar-icon-turns-white-in-android-5-lollipop

I have an app showing custom notifications. The problem is that when running in Android 5 the small icon in the Notification bar shows white. How can I fix this?

The accepted answer is not (entirely) correct. Sure, it makes notification icons show in color, but does so with a BIG drawback - by setting the target SDK to lower than Android Lollipop!

If you solve your white icon problem by setting your target SDK to 20, as suggested, your app will not target Android Lollipop, which means that you cannot use Lollipop-specific features.

Have a look at , and you'll see that the white style is how notifications are meant to be displayed in Android Lollipop.

In Lollipop, Google also suggest that you use a color that will be displayed behind the (white) notification icon - 

So, I think that a better solution is to add a silhouette icon to the app and use it if the device is running Android Lollipop.

For instance:

Notification notification = new Notification.Builder(context) .setAutoCancel(true) .setContentTitle("My notification") .setContentText("Look, white in Lollipop, else color!") .setSmallIcon(getNotificationIcon()) .build(); return notification;

And, in the getNotificationIcon method:

private int getNotificationIcon() { boolean whiteIcon = (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP); return whiteIcon ? R.drawable.icon_silhouette : R.drawable.ic_launcher; }

转载于:https://www.cnblogs.com/lotusJade/p/4863802.html

你可能感兴趣的文章
Apache OFBiz 10.04.05 发布,安全漏洞修复
查看>>
京东书4
查看>>
Java EE之RMI
查看>>
ASCII编码表 -- SQL注入 也需要
查看>>
MySQL常用数据类型介绍
查看>>
当装系统时遇到“选中的磁盘采用GPT分区形式”
查看>>
CentOS的远程桌面(xdm)
查看>>
Some aspects to prepare
查看>>
oracle 好书 05 ( 内存组件与 oracle 进程 )
查看>>
Linux gdb符号调试器
查看>>
http_load
查看>>
metasploit tutorial
查看>>
安装 iis 的方式
查看>>
Spring MVC 拦截器问题,如何配置不需要拦截的页面
查看>>
覆盖距离AsiaHatyai-2012 & LA 6144 - Radiation 二分搜索
查看>>
LINQ : IEnumerable<T> and IQueryable<T>区别
查看>>
版本浏览器最流行的JavaScript库,jQuery不再支持IE旧版本
查看>>
斜水印,重复水印,文字
查看>>
ios开发之启动画面及动画
查看>>
在线机器学习算法及其伪代码
查看>>