gpt4 book ai didi

安卓 5( Lollipop ): Is it possible to make the Background of a Notification transparent?

转载 作者:太空宇宙 更新时间:2023-11-03 13:21:40 24 4
gpt4 key购买 nike

有什么方法可以让Android中的通知背景透明吗?我通过将 RemoteViews 与 Layout 和 NotificationCompat 结合使用来创建通知:

    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 中,背景始终显示为白色。

最佳答案

很遗憾,没有办法。

白色是通知行的背景,而不是通知本身。您的透明 RemoteViews 绘制在通知行的顶部。

技术细节:

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

根据源代码,唯一可以覆盖此颜色的地方是setTintColor method。 , 但它仅从 BaseStatusBar.java and only for media notifications 调用.

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

关于安卓 5( Lollipop ): Is it possible to make the Background of a Notification transparent?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26944475/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com