简体   繁体   English

android - android 5中的白色圆圈通知图标

[英]android - white circle notification icon in android 5

I've a problem with the notification icon in android . 我在android中的通知图标有问题。

this is my code : 这是我的代码:

Notification myNotification = new NotificationCompat.Builder(ctx)
                .setSmallIcon(getNotificationIcon())
                .setAutoCancel(false).setContentTitle(onvan)
                .setStyle(new NotificationCompat.BigTextStyle().bigText(msg)).setContentText(msg)
                .setContentIntent(pending).build();

        long number = (long) Math.floor(Math.random() * 9000000000L) + 1000000000L;
        notificationManager.notify((int) number, myNotification);


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

What is the problem ? 问题是什么 ?

Post android Lollipop release android has changed the guidelines for displaying notification icons in the Notification bar. 发布android Lollipop发布android已经改变了通知栏中显示通知图标的指导原则。 The official documentation says "Update or remove assets that involve color. The system ignores all non-alpha channels in action icons and in the main notification icon. You should assume that these icons will be alpha-only. The system draws notification icons in white and action icons in dark gray.” Now what that means in lay man terms is "Convert all parts of the image that you don't want to show to transparent pixels. 官方文档说“更新或删除涉及颜色的资产。系统会忽略操作图标和主要通知图标中的所有非alpha通道。您应该假设这些图标仅为alpha。系统以白色绘制通知图标暗灰色中的动作图标。“现在,在外行人的术语中意味着”将您不想显示的图像的所有部分转换为透明像素。 All colors and non transparent pixels are displayed in white" 所有颜色和非透明像素均以白色显示“

You can see how to do this in detail with screenshots here https://blog.clevertap.com/fixing-notification-icon-for-android-lollipop-and-above/ 您可以通过此处的屏幕截图详细了解如何执行此操作https://blog.clevertap.com/fixing-notification-icon-for-android-lollipop-and-above/

Hope that helps 希望有所帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM