2015-07-21 75 views
0

我有这样的代码空白图标

Notification.Builder builder = new Notification.Builder(context) 
       .setSmallIcon(R.drawable.ic_launcher) 
       .setContentTitle("My notification") 
       .setContentText("Hello World!") 
       .setAutoCancel(true) 
       .setTicker("texto") 
       .setWhen(System.currentTimeMillis()); 

     Notification n = builder.getNotification(); 
     NotificationManager notifManager = (NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE); 

     int notif_ref = 1; 

     notifManager.notify(notif_ref, n); 

但是,当启用了股票我有一个空白图标

enter image description here

enter image description here

谢谢!

+2

由于使用了R.drawable.ic_launcher,我认为您使用了错误的大小,因此您应该为通知图标使用ad-hoc大小。另外,你没有设计指导。通知图标必须是白色和平坦的。 – greywolf82

+1

添加到@ greywolf82说,在棒棒糖和操作系统强制通知图标是白色的,所以它会像你看到的第一个图像。更好地坚持准则 – tyczj

+0

是的!有用!谢谢 – benoffi7

回答

0

由于@ greywolf82和@tycz说问题没有使用更正大小。谢谢!

MDPI - 24 x 24 (drawable-mdpi) 

HDPI - 36 x 36 (drawable-hdpi) 

XHDPI - 48 x 48 (drawable-xhdpi) 

XXHDPI - 72 x 72 (drawable-xxhdpi) 

XXXHDPI - 96 x 96 (drawable-xxxhdpi)