0

I want to create Android notification with transparent background. I'm using bigContent with remoteViews to create my own layout, but when i set background color of main layout to @android/color/transparent nothing happens. I still see standard white background of notification.

How can I set transparent background on Android notification? I note that i don't mean notification bar (or status bar) but background of custom notification.

4

1 回答 1

2

正如 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>

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

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

于 2015-07-26T18:40:26.583 回答