Android 5 (Lollipop): Is it possible to make the background notification transparent?

Is there a way to make the background of an alert in Android transparent? I am creating a notification using RemoteViews with layouts and NotificationCompat:

    RemoteViews rv = new RemoteViews(getPackageName(), R.layout.notification_layout);

    NotificationCompat.Builder mBuilder =
            new NotificationCompat.Builder(this)
                    .setSmallIcon(R.drawable.ic_launcher)
                    .setContent(rv);

      

The background of the LinearLayout is set to transparent. But in Lollipop, the background is always displayed as white.

+3


source to share


1 answer


Unfortunately there is no way.

White is the background of the notification bar, not the notification itself. Your transparent is RemoteViews

drawn on top of the notification bar.

Technical details:



The appearance of notifications is defined in the SystemUI package . White is defined in colors.xml and used in ActivatableNotificationView.java .

According to the source code, the only place this color can be overridden is in the setTintColor method , but it is only called from BaseStatusBar.java and only for media notifications .

However, even for media notificaitons, transparent color does not work, perhaps because of setAlpha(1)

.

+4


source







All Articles