2016-08-01 48 views
0

我想在我的Android應用程序中實現豐富多彩的自定義通知。Android炫彩通知圖片

我試圖實現顏色,但目前我只能設置背景顏色。我想達到這樣的結果: enter image description here

我的應用程序的圖像顯示爲通知圖片展開時。

這裏我的代碼的時刻:

return builder.setContentTitle("APP TITLE") 
       .setContentText("Some texts") 
       .setSmallIcon(R.mipmap.ic_launcher) 
       .setContentIntent(pendingIntent) 
       .setOngoing(true) 
       .setAutoCancel(true)   
       .setVisibility(Notification.VISIBILITY_PUBLIC) 
       .setPriority(Notification.PRIORITY_HIGH) 
       .setCategory(Notification.CATEGORY_ALARM) 
       .setOnlyAlertOnce(false) 
       .setColor(getResources().getColor(R.color.colorPrimary)); 

我如何能實現圖標通知豐富多彩,爲視頻羣聊的例子,我張貼以上?

回答

1
mNotifyBuilder = new NotificationCompat.Builder(this) 
       .setContentTitle(getResources().getString(R.string.app_name)) 
       .setContentText(messs) 
       .setLargeIcon(bitmap) 
       .setSmallIcon(R.mipmap.hangouts_launcher) 
       .setStyle(new NotificationCompat.BigTextStyle().bigText(message)); 
mNotifyBuilder.setContentIntent(pIntent); 
// Set Vibrate, Sound and Light            
     int defaults = 0; 
     defaults = defaults | Notification.DEFAULT_LIGHTS; 
     defaults = defaults | Notification.DEFAULT_VIBRATE; 
     defaults = defaults | Notification.DEFAULT_SOUND; 
     mNotifyBuilder.setDefaults(defaults); 
     // Set the content for Notification 
     mNotifyBuilder.setContentText(messs); 
mNotificationManager.notify(m, mNotifyBuilder.build());