简体   繁体   English

Android L中的通知栏图标变为白色

[英]Notification bar icon turns white in Android L

I'm using a remote view for custom notification layout. 我正在使用远程视图进行自定义通知布局。 Everything works fine. 一切正常。 Only problem that I'm facing is the notification is displayed as a white circle in the notification status bar. 我遇到的唯一问题是通知在通知状态栏中显示为白色圆圈。 I want my app icon to be shown in the notification status bar(how it shows in kitkat & lower versions). 我希望我的应用程序图标显示在通知状态栏中(如何在kitkat及更低版本中显示)。 is there any way to change this? 有没有办法改变这个?

private void showNotification() {

        Intent intent = new Intent(this, HomeActivity.class);
        intent.putExtra(LIVE_RADIO_PUSH, true);
        PendingIntent pendingIntent = PendingIntent.getActivity(this, 1, intent, 0);
        mBuilder = new NotificationCompat.Builder(this);
        mBuilder.setCategory(Notification.CATEGORY_SERVICE);
        mBuilder.setContentTitle(mTitle);
        mBuilder.setContentText("Live Radio");
        mBuilder.setSmallIcon(R.drawable.logo);
        mBuilder.setWhen(System.currentTimeMillis());
        mBuilder.setVisibility(Notification.VISIBILITY_PUBLIC);
        mBuilder.setContentIntent(pendingIntent);
        mBuilder.setColor(getResources().getColor(R.color.theme_primary));
        mNotificationView = new RemoteViews(getPackageName(), R.layout.notification_layout);
        mNotificationView.setTextViewText(R.id.content_title, mTitle);
        mNotificationView.setTextViewText(R.id.content_text, "Live Radio");
        SimpleDateFormat dateFormat = new SimpleDateFormat("hh:mm");
        String time = dateFormat.format(new Date(System.currentTimeMillis()));
        mNotificationView.setTextViewText(R.id.current_time, time);
        mNotificationView.setImageViewResource(R.id.play_pause, R.drawable.pause_radio);
        mNotificationView.setImageViewResource(R.id.close_btn, R.drawable.notifictn_close_btn);


        setListeners(mNotificationView);
        mBuilder.setContent(mNotificationView);
        Log.d(TAG, "App is freezed2");
        if (null != mNotificationMngr)
            mNotificationMngr.notify(RADIO_NOTIFICATION_ID, mBuilder.build());
    }

I have encountered this issue too, as you mention, if your ANDROID_BUILD_TARGET_SDK_VERSION = 21, it will change this notification into white. 我也遇到过这个问题,如你所说,如果您的ANDROID_BUILD_TARGET_SDK_VERSION = 21,它会将此通知更改为白色。

The notification icon design guideline as this link. 通知图标设计指南为此链接。 http://developer.android.com/design/style/iconography.html http://developer.android.com/design/style/iconography.html

Recently we done one application with notification.Its working fine in lollipop also.Once check the below code may be it will helps you. 最近我们做了一个带通知的应用程序。它在棒棒糖中工作正常。一旦检查下面的代码可能会对你有帮助。

mNotification = new Notification.Builder(this).setContentTitle("M3 Media Player").setContentIntent(mPendingIntentHome)
                    .setSmallIcon(R.drawable.app_icon).setPriority(Notification.PRIORITY_MAX).setContent(mNotificationContentView)
                    .setStyle(new Notification.BigPictureStyle()).build();

If your compileSDKversion is above 20 then notification icon should be a white-on-transparent background image. 如果您的compileSDKversion大于20,那么通知图标应该是透明的白色背景图像。 Otherwise the image will be rendered as a white colored image. 否则,图像将呈现为白色图像。

Please go through the below link too for guidelines to create the icon 请仔细阅读以下链接,以获取创建图标的指导

https://www.google.com/design/spec/patterns/notifications.html https://www.google.com/design/spec/patterns/notifications.html

and also the notification icon generator. 以及通知图标生成器。

https://romannurik.github.io/AndroidAssetStudio/icons-notification.html#source.space.trim=1&source.space.pad=0&name=ic_stat_example https://romannurik.github.io/AndroidAssetStudio/icons-notification.html#source.space.trim=1&source.space.pad=0&name=ic_stat_example

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM