Android 通知背景为灰色正方形
当显示notif时,将显示图标。但当我展开通知菜单时,它是一个灰色图标 我的舱单:Android 通知背景为灰色正方形,android,firebase,firebase-cloud-messaging,android-notifications,Android,Firebase,Firebase Cloud Messaging,Android Notifications,当显示notif时,将显示图标。但当我展开通知菜单时,它是一个灰色图标 我的舱单: <meta-data android:name="com.google.firebase.messaging.default_notification_icon" android:resource="@drawable/ic_notification" /> <meta-data android:name="com.google.fir
<meta-data
android:name="com.google.firebase.messaging.default_notification_icon"
android:resource="@drawable/ic_notification" />
<meta-data
android:name="com.google.firebase.messaging.default_notification_color"
android:resource="@android:color/transparent" />
例如,在此屏幕截图中,将显示图标(绿色图标):
但是:
对于上述棒棒糖操作系统设备,通知图标背景颜色应为灰色,并应遵循android提供的通知图标指南 如果在KitKat中运行相同的应用程序,现有的应用程序可以正常工作 无论如何,有一个解决办法, 但当你的应用程序处于关闭状态时,它将无法工作 查看以下链接了解图标设计指南
对于上述棒棒糖操作系统设备,通知图标背景颜色应为灰色,并应遵循android提供的通知图标指南 如果在KitKat中运行相同的应用程序,现有的应用程序可以正常工作 无论如何,有一个解决办法, 但当你的应用程序处于关闭状态时,它将无法工作 查看以下链接了解图标设计指南 使用了两个通知图标 1) 透明背景。示例图标: 2) 颜色(通常使用“ic_启动器_图标”) 使用了两个通知图标 1) 透明背景。示例图标:
2) 颜色(通常使用“ic启动图标”)它将根据alpha/颜色将其转换为灰度。由于您的整个图像没有alpha,因此它创建了一个灰度正方形,并根据alpha/颜色将其转换为灰度。因为您的整个图像没有alpha,所以它正在创建一个灰色正方形
NotificationCompat.Builder builder = new NotificationCompat.Builder(getContext(), notificationId+"")
.setContentTitle(getContext().getString(R.string.app_name))
.setContentText(message.getAlert())
.setAutoCancel(true);
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
builder.setSmallIcon(R.drawable.notification_icon_transparent);
} else {
builder.setSmallIcon(R.drawable.notification_icon_color);
}