如何在Android 5.0以上使用Notification icon.md

如何在Android 5.0以上使用Notification icon.md

這次的範例從如何使用Notification修改的,在 Android 5.0 以上,Google 建議你使用白色跟透明的icon,否則這樣的 icon 會在 Notification 上面被塗成白色。


就會出現這樣醜醜的畫面。


查了一下官網的說明。
https://developer.android.com/about/versions/android-5.0-changes.html#BehaviorNotifications

Update or remove assets that involve color. 
The system ignores all non-alpha channels in action icons and 
in the main notification icon. 
You should assume that these icons will be alpha-only. 
The system draws notification icons in white and action icons in dark gray.

忽略所有非透明的 notification icon 部分,且會把非透明的部分塗成白色。
因此你必須丟出類似這樣的畫面。


除了房子周圍部分是透明的,主要的顏色會被塗成白色。



基本上就不怎麼影響了。
當然你也可以根據如何透過Android Studio產生向量圖來做一個icon。


就可以看到 Android 機器人跑在上面。


Google 提供了許多系統 icon 可以讓你直接套用。
https://design.google.com/icons/