Android N notification title and icon color is darker

风流意气都作罢 提交于 2019-12-03 11:40:32

问题


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

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.

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


回答1:


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.

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



来源:https://stackoverflow.com/questions/47590944/android-n-notification-title-and-icon-color-is-darker

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!