【问题标题】:Notifcation status icons become white when i genreate notification in andorid 5.0当我在 andorid 5.0 中生成通知时,通知状态图标变为白色
【发布时间】: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


【解决方案1】:

经过一番搜索,看起来从 andorid 5.0 开始,我们只能在透明背景图像上使用白色,只有我在开发者网站下面阅读过它

Android notification guide

从上面的网站他们在下面说

Notification icons should only be a white-on-transparent background image.

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-02-24
    • 1970-01-01
    • 1970-01-01
    • 2016-05-01
    • 2017-09-15
    • 2015-04-07
    • 1970-01-01
    相关资源
    最近更新 更多