Reputation: 43
Is there any way to make the Background of a Notification in Android transparent? I'm creating a Notification by using RemoteViews with a Layout 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 layout's LinearLayout is set to transparent. But in Lollipop the Background is always shown as white.
Upvotes: 3
Views: 742
Reputation: 4175
Unfortunately, there is no way.
White color is the background of the notification row, not the notification itself. Your transparent RemoteViews
is drawn on top of the notification row.
Technical details:
Appearance of notifications is defined in the SystemUI package. White color is defined in colors.xml, and is used in ActivatableNotificationView.java.
According to the source code, the only place where this color can be overriden is the setTintColor method, but it is called only from BaseStatusBar.java and only for media notifications.
However even for media notificaitons transparent color does not work, probably because of setAlpha(1)
.
Upvotes: 4