Android 中的透明通知背景
Transparent notification background in Android
我想创建 Android 具有透明背景的通知。我将 bigContent 与 remoteViews 一起使用来创建我自己的布局,但是当我将主布局的背景颜色设置为 @android/color/transparent 时,没有任何反应。我仍然看到通知的标准白色背景。
如何在 Android 通知上设置透明背景?
我注意到我不是指通知栏(或状态栏)而是自定义通知的背景。
正如 CommonsWare 在评论中所说,这是不可能的。
除非 phone 制造商更改(这很可能是不允许的)通知是分层构建的。底层是背景视图,它在棒棒糖上有一个灰色(不记得我脑海中的棒棒糖之前)在背景视图之上你有通知提供的内容视图(你可以制作的视图).当您使视图透明时,您会显示背景。您无法更改背景。
在棒棒糖上这些是默认值:
<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
我想创建 Android 具有透明背景的通知。我将 bigContent 与 remoteViews 一起使用来创建我自己的布局,但是当我将主布局的背景颜色设置为 @android/color/transparent 时,没有任何反应。我仍然看到通知的标准白色背景。
如何在 Android 通知上设置透明背景? 我注意到我不是指通知栏(或状态栏)而是自定义通知的背景。
正如 CommonsWare 在评论中所说,这是不可能的。
除非 phone 制造商更改(这很可能是不允许的)通知是分层构建的。底层是背景视图,它在棒棒糖上有一个灰色(不记得我脑海中的棒棒糖之前)在背景视图之上你有通知提供的内容视图(你可以制作的视图).当您使视图透明时,您会显示背景。您无法更改背景。
在棒棒糖上这些是默认值:
<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