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

时间:2016-06-12 05:29:48

标签: android android-5.0-lollipop android-notifications

我在android中遇到了通知图标问题。

这是我的代码:

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;
}

有什么问题?

1 个答案:

答案 0 :(得分:0)

发布android Lollipop发布android已更改了通知栏中显示通知图标的指南。官方文档说"更新或删除涉及颜色的资产。系统会忽略操作图标和主通知图标中的所有非Alpha通道。您应该假设这些图标仅为alpha。系统以白色绘制通知图标,以深灰色绘制动作图标。“现在,在男人的术语中,这意味着"将您不想显示的图像的所有部分转换为透明像素。所有颜色和非透明像素均以白色"

显示

您可以在https://blog.clevertap.com/fixing-notification-icon-for-android-lollipop-and-above/

屏幕截图中详细了解如何执行此操作

希望有所帮助