Android透明的通知背景



我想创建一个透明背景的Android通知。我使用bigContent与remoteViews来创建我自己的布局,但是当我设置主布局的背景颜色为@android/color/transparent时,什么都没有发生。我仍然看到标准的白色背景通知。

如何设置Android通知透明背景?我不是指通知栏(或状态栏),而是指自定义通知的背景。

正如CommonsWare在评论中所说,这是不可能的。

除非由手机制造商更改(这很可能是不允许的),通知是分层构建的。底层是背景视图,它有一个灰色的棒棒糖(我不记得棒棒糖的顶部)在背景视图的顶部你有通知提供的内容视图(你可以制作的视图)。当你使视图透明时,你就会显示背景。你不能改变背景。

在棒棒糖上这些是默认值:

<color name="notification_legacy_background_color">#ff1a1a1a</color>
<!-- The color of the material notification background -->
<color name="notification_material_background_color">#fffafafa</color>
<!-- The color of the material notification background when dimmed -->
<color name="notification_material_background_dimmed_color">#d4ffffff</color>
 <!-- The color of the material notification background when low priority -->
<color name="notification_material_background_low_priority_color">#ffe0e0e0</color>
<!-- The color of the material notification background for media notifications when no custom
     color is specified -->
<color name="notification_material_background_media_default_color">#ff424242</color>

更多信息:80年http://androidxref.com/5.1.1_r6/xref/frameworks/base/packages/SystemUI/res/values/colors.xml

http://androidxref.com/5.1.1_r6/xref/frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/ActivatableNotificationView.java

最新更新