gpt4 book ai didi

android - Nexus 5 通知栏中的白色图标

转载 作者:行者123 更新时间:2023-11-29 01:35:05 25 4
gpt4 key购买 nike

令人惊讶的是,我的应用程序图标在我的 Nexus 5 的通知栏中出现了白色图标。这仅在 Nexus 5 中。

enter image description here

关于这个已经有一个问题,答案显示我需要:目标 20。我已经尝试过:如下所示,没有区别。

defaultConfig 
{
applicationId "com.cn.redquest"
minSdkVersion 20
targetSdkVersion 20
versionCode 10
versionName "1.00"
}

有人可以帮我解决这个问题吗?

告诉我!

谢谢!

最佳答案

将目标 SDK 设置为 20 意味着您不为 Android Lollipop 构建应用。这将使您的通知图标显示所有颜色,但这不是一个长期的解决方案,因为您将想要为 Lollipop 构建(至少最终)。

http://developer.android.com/design/style/iconography.html您可以了解到白色样式是通知在 Lollipop (SDK 21) 中的显示方式。 Google 还建议使用自定义背景色 - https://developer.android.com/about/versions/android-5.0-changes.html

如果设备运行的是 Android Lollipop,我认为更好的解决方案是实际为系统提供剪影图标。

例如:

Notification notification = new Notification.Builder(context)
.setAutoCancel(true)
.setContentTitle("My notification")
.setContentText("Look, white in Lollipop, else color!")
.setSmallIcon(getNotificationIcon())
.build();

并且,在 getNotificationIcon 方法中:

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

关于android - Nexus 5 通知栏中的白色图标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28803190/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com