android 7.0 Notification icon appearing white square

假如想象 提交于 2019-12-05 07:59:54
Ichigo Kurosaki

From android version lollpop onwards, they have made the changes for the notifications. When you are specifing the small icon, it should be of specific size as mentioned in this link.

The important thing is the image should be transparent and contains only white color.

You can check this question to get the answer

Following the docs from the Android API:

Status bar icons are composed simply of white pixels on a transparent backdrop, with alpha blending used for smooth edges and internal texture where appropriate.

Your whole image but the transparent parts is going to be converted to white (being originally white or having colors).

One solution is to create a silhouette icon with color, by this way you can use the same image in all Android APIs. One example could be this icon:

In lower versions of Android you would see the black face, in the last versions you will see the same face but with white color. That's because of the transparent parts (it seems SO removes the transparency, you can get the original from here) of the image.

According to this blog here

It says that

You’ll note that the icons are not present in the new notifications; instead more room is provided for the labels themselves in the constrained space of the notification shade. However, the notification action icons are still required and continue to be used on older versions of Android and on devices such as Android Wear.

If you’ve been building your notification with NotificationCompat.Builder and the standard styles available to you there, you’ll get the new look and feel by default with no code changes required.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!