【发布时间】:2014-12-18 11:07:59
【问题描述】:
当我在 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 午餐图标在通知的状态栏中变成白色以及如何解决它。
以下是屏幕截图
【问题讨论】:
-
我认为你不能影响它?棒棒糖的通知发生了很大变化,它的颜色总是白色/灰色+透明度。最好等待有人确认,但在 android 5.0+ 中的 AFAIK 就像在状态栏中一样......
-
@MarkoNiciforovic 是的,你是对的,但如果有人能够使用彩色完整通知图标,我仍然会期待。
-
我怀疑你可以改变它。在状态栏中我认为它总是会是白色+透明的,在“行动”中你可以设置你想要的任何东西
标签: android android-notifications