【发布时间】:2016-06-23 16:56:57
【问题描述】:
我在通知中显示图标时遇到问题。我已经通过material designs page 的图标和Notification doc。
我使用了不同的比例,在 BMP 256 颜色格式中:360px、144px、48px、24px 16px 都继续显示白色块。
我将格式更改为 PNG,使用 144px(命名为“ic_notify_icon”,在代码中使用),仍然没有运气。
//Global
private NotificationManager mNotifyManager ;
private Notification mNotify;
private void initialize() {
mNotifyManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
Notification.Builder mNotificationBuilder = new Notification.Builder(this);
mNotificationBuilder.setSmallIcon(R.mipmap.ic_notify_icon);
mNotificationBuilder.setContentTitle("A Title here");
mNotificationBuilder.setContentText("Some content text here");
mNotify = mNotificationBuilder.build();
ShowNotify();
}
private void ShowNotify(){
//...some code here
mNotifyMan.notify(0, mNotify);
//...some code here
}
有什么建议吗?
附言我看过this post,也是同样的问题,但我觉得它没有帮助/有用,或者我只是不明白要求...
【问题讨论】:
-
您的通知图片是什么样的?有透明度吗?
-
不,这是一个简单的白色背景,颜色为大 5,用 MS 油漆制作 - 用于调试的快速图标
-
是的,这就是问题所在。为了保持一致的外观,生成了图标,以便可以使它们与主题相匹配。您必须将其仅视为前景色和透明度。
-
@CaseyB 我为我如何解决我的问题添加了一个深入的答案,如果你觉得有必要,你可以看看和改进
标签: android image icons android-notifications