相关疑难解决方法(0)

Android颜色通知图标

我正在开发一个应用程序,我在那里为用户创建通知.我希望图标在状态栏中显示为白色,但在下拉通知菜单中显示时显示为蓝色.以下是Google Store应用程序执行相同操作的示例.

状态栏中的白色通知:

在此输入图像描述

下拉菜单中的彩色通知:

在此输入图像描述

我怎么能复制这个?我需要设置哪些属性?

编辑: 这是我当前的代码 - 我使图像全白,透明背景,所以它在状态栏中看起来很好,但在通知中,图像仍然是相同的白色:

private NotificationCompat.Builder getNotificationBuilder() {
        return new NotificationCompat.Builder(mainActivity)
                .setDeleteIntent(deletedPendingIntent)
                .setContentIntent(startChatPendingIntent)
                .setAutoCancel(true)
                .setSmallIcon(R.drawable.skylight_notification)
                .setColor(ContextCompat.getColor(mainActivity, R.color.colorPrimary))
                .setContentTitle(mainActivity.getString(R.string.notification_title))
                .setContentText(mainActivity.getString(R.string.notification_prompt));
    }
Run Code Online (Sandbox Code Playgroud)

java android colors push-notification android-notifications

34
推荐指数
5
解决办法
3万
查看次数