Android 5(棒棒糖):是否可以使通知的背景透明?

3
有没有办法让Android通知的背景透明?我正在使用带有布局和NotificationCompat的RemoteViews创建通知:
    RemoteViews rv = new RemoteViews(getPackageName(), R.layout.notification_layout);

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

布局的LinearLayout的背景设置为透明。但在Lollipop中,背景总是显示为白色。
1个回答

4

很遗憾,没有办法。

白色是“通知行”的背景颜色,而不是通知本身。您的透明RemoteViews将绘制在通知行之上。

技术细节:

通知的外观定义在SystemUI包中。白色在colors.xml中定义,并在ActivatableNotificationView.java中使用。

根据源代码,唯一可以覆盖此颜色的地方是setTintColor方法,但仅从BaseStatusBar.java并且仅用于媒体通知调用。

然而,即使对于媒体通知,透明颜色也不起作用,可能是因为setAlpha(1)


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接