Notification bar icon turns white in Android 5 Lollipop

编程入门 行业动态 更新时间:2024-10-27 19:24:41

Notification bar <a href=https://www.elefans.com/category/jswz/34/1753057.html style=icon turns white in Android 5 Lollipop"/>

Notification bar icon turns white in Android 5 Lollipop

问题浅析见博客:.html
从,尝试成功。只实现了白色图案。一定要完全按照下面的设置来。
To avoid Notification icons to turn white, use “Silhouette” icons for them, ie. white-on-transparent background images. You may use Irfanview to build them:

   choose a picture, open in [IrfanView](/), press F12 for the painting tools, clean picture if necessary (remove unwanted parts, smooth and polish)Image / Decrease Color Depth to **2** (for a black & white picture)Image / Negative (for a white on black picture)(//没太明白什么意思,可以选all channel)Image / Resize/Resample to 144 x 144 (**use Size Method "Resize"** not "Resample", otherwise picture is increased to 24 color bits per pixel (24 BPP) againFile / Save as PNG, check Show option dialog, check **Save Transparent Color**, click Save, then click on the black color in the image to set **the transparent color**

Android seems to be using the drawable-xxhdpi picture resolution (144 x 144) only, so copy your resulting ic_notification.png file to \AndroidStudio\Projects…\app\src\main\res\drawable-xxhdpi. Use .setSmallIcon(R.drawable.ic_notification) in your code, or use getNotificationIcon() as Daniel Saidi suggested above.

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

更多推荐

Notification bar icon turns white in Android 5 Lollipop

本文发布于:2024-03-13 09:05:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1733629.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:icon   bar   Notification   turns   Lollipop

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!