当我在android 5(L)
中使用以下代码时,我的通知图标变为白色这是我的代码:
private void generateSimpleNotification(){
NotificationCompat.Builder mNotificationBuilder=new NotificationCompat.Builder(this);
mNotificationBuilder.setSmallIcon(R.drawable.ic_launcher);
mNotificationBuilder.setContentText("App notification text here");
mNotificationBuilder.setContentTitle("App notification Title here");
// Creates an explicit intent for an Activity in your app
Intent resultIntent=new Intent(this,NotificationActivity.class);
// The stack builder object will contain an artificial back stack for the
// started Activity.
// This ensures that navigating backward from the Activity leads out of
// your application to the Home screen.
TaskStackBuilder mStackBuilder=TaskStackBuilder.create(this);
// Adds the back stack for the Intent (but not the Intent itself)
mStackBuilder.addParentStack(NotificationParentActivity.class);
// Adds the Intent that starts the Activity to the top of the stack
mStackBuilder.addNextIntent(resultIntent);
PendingIntent mPendingIntent=mStackBuilder.getPendingIntent(0,PendingIntent.FLAG_UPDATE_CURRENT);
mNotificationBuilder.setContentIntent(mPendingIntent);
NotificationManager mNotificationManager =
(NotificationManager) getSystemService(
Context.NOTIFICATION_SERVICE);
// mId allows you to update the notification later on.
mNotificationManager.notify(0, mNotificationBuilder.build());
}
我使用setSmallIcon(R.drawable.ic_launcher);
以下是图标大小
drawable-hdpi 72x72
drawable-mdpi 48x48
drawable-xhdpi 96x96
drawable-xhdpi 144x144
现在问题是我的android luncher图标在我的通知状态栏中变为白色以及如何解决它。
下面的是屏幕截图
答案 0 :(得分:4)
在搜索了一下后,它看起来像是从andorid 5.0我们只能在透明背景图像上使用白色我只在开发者网站下面阅读
从上面的网站上面说过
Notification icons should only be a white-on-transparent background image.