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
发布评论