Android N通知标题和图标颜色变深 [英] Android N notification title and icon color is darker

查看:208
本文介绍了Android N通知标题和图标颜色变深的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在android N和O中显示通知时,其显示如下

When showing a notification in android N and O it shows like this

您可以使用NotificationCompat.BuildersetColor方法更改图标的顶部颜色和应用程序名称,问题是显示的颜色与提供的颜色不匹配,因为它变得较暗.

You can change the top color of the icon and the app name by using setColor method of the NotificationCompat.Builder, The problem is that the displayed color doesn't match the provided one as it gets darker in the notification.

我在Google Pixel(Oreo)上进行了测试.这是在某处记录的吗?有任何解决方法吗?

I tested it on Google Pixel(Oreo). Is this documented somewhere? Any workarounds?

推荐答案

Google决定在通知(使用 setColor .是的,它是无证的,未经请求的,并且邪恶!经过一些探索(黑客的方式)后,可能会在(内部)

Google decided to restrict acceptable colors in Notification when using setColor. Yes, it's undocumented, unsolicited and evil! After some digging (hacker's way) it may be found in the source code of (internal) NotificationColorUtil. Inspect line 300 (findContrastColor) and 474 (resolveContrastColor) where the rationale is:

解决通知的颜色,使其具有足够的对比度 用作通知操作和标题文本的颜色.

Resolves a Notification's color such that it has enough contrast to be used as the color for the Notification's action and header text.

我不同意. Google应该更了解并且不作恶自由设计者和开发者的美学选择.

I do not agree. Google should have known better and be doing no evil to the freedom of aesthetic choices of designers and developers.

这篇关于Android N通知标题和图标颜色变深的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆