2014-12-27 91 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

相關問題