Android通知小图标背景始终是黑色的

问题描述 投票:2回答:1

我用NotificationBuilder为android创建了通知,虽然我设置了.setColor(),它忽略了颜色并将小图标的背景颜色设置为黑色。我的目标SDK是23,min SDK是19.而我用于调试的手机有Android Marshmallow.Thanks寻求帮助。

.setContentTitle(msgTitle)
        .setSmallIcon(R.mipmap.notification_icon)
        .setColor(R.color.ColorPrime) // ColorPrime is red.
        .setLargeIcon(msgIcon)
        .setTicker(msgBody)
            .setStyle(new NotificationCompat.BigTextStyle()
                    .bigText(msgBody).setBigContentTitle(msgTitle))
        .setContentText(msgBody)
        .setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION))
        .setPriority(Notification.PRIORITY_HIGH);

Preview

android android-5.0-lollipop android-notifications android-6.0-marshmallow android-statusbar
1个回答
7
投票

解决了它。

而不是.setColor(R.color.ColorPrime)使用.setColor(getResources().getColor(R.color.ColorPrime))完全工作。

© www.soinside.com 2019 - 2024. All rights reserved.