2014-12-27 133 views
4

下面是我用来显示通知的代码。通知图标不显示在棒棒糖的状态栏中

notification = new Notification.Builder(context).setContentIntent(contentIntentTwo) 
         .setContentTitle("App name").setSmallIcon(R.drawable.ic_launcher).setLargeIcon(notificationLargeIconBitmap).getNotification(); 

通知和通知图标显示在下拉通知抽屉中,但不显示在棒棒糖状态栏中。

这里是什么样子的棒棒糖:

enter image description here

这种情况只有在棒棒糖。

+0

这将发布链接,如果你找到了更好的解决方案在别处是个好主意。对于其他人,OP在这里问了同样的问题,得到了更好的回复:http://www.reddit.com/r/androiddev/comments/2qjsal/notification_icon_shows_in_white_in_status_bar/ – Nirmal 2015-02-10 21:08:11

回答

2
+0

所以,我需要做的就是'setcolor( )'?你可以再详细一点吗?我只是阅读文档,我可以从中得出的唯一结论是使用setcolor – user4351462 2014-12-27 17:40:21

+0

“系统忽略动作图标和主通知图标中的所有非alpha通道,您应该假定这些图标将仅为alpha-only系统以白色和动作图标以深灰色绘制通知图标。“ – tachyonflux 2014-12-27 17:44:11

+0

我刚才说我读过文档。我的问题依然存在。 – user4351462 2014-12-27 17:45:17

0

的棒棒糖之前的版本,你仍然可以使用绘制的图像。但对于棒棒糖和以后,你需要透明的背景图像用于通知图标(首选png)。据我所知,棒棒糖版本或更高版本会将任何非透明颜色转换成白色,以便通知图标​​,因为其简单和“肤色减少”的想法可以达到材料设计。

NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context) 
      .setContentTitle(title) 
      .setContentText(body) 
      .setPriority(2) 
      .setContentIntent(pendingIntent); 
    mBuilder.setAutoCancel(true); 
    if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){ 
     mBuilder.setSmallIcon(R.mipmap.ic_launcher_transparant); 
    }else{ 
     mBuilder.setSmallIcon(R.mipmap.ic_launcher); 
    } 

https://medium.com/swarm-nyc/complexion-reduction-a-new-trend-in-mobile-design-cef033a0b978#.fblfw0ohi