自定义推送通知 - 全宽背景颜色

发布于 2025-01-25 04:17:55 字数 1256 浏览 2 评论 0原文

我正在实施自定义推送通知。我有一个自定义布局,使用远程视图进行了修改。我已经使用了使用颜色

        contentView.setInt(R.id.parentLayout, "setBackgroundColor", Color.parseColor("#4979C5"))

        notifBuilder.setColor(Color.parseColor("#4979C5"))
       .setColorized(true)

,但并未将颜色完全设置在背景上。我希望它具有这样的Android系统通知

”在此处输入图像说明“

但我得到了

这是我使用的样式:

notifBuilder.setColorized(true)
                .setColor(Color.parseColor("#4979C5"))
                .setStyle(NotificationCompat.DecoratedCustomViewStyle())
                .setContent(closedView)
                .setCustomBigContentView(contentView)
                .setSmallIcon(R.drawable.icon_tick)

我尝试使用其他样式并删除了该样式样式,但我得到了这个结果

”“在此处输入图像说明”

似乎很好,因为它确实在完整的通知区域设置了背景颜色,但现在没有诸如应用程序名称,通知时间,应用程序图标和展开图标之类的详细信息。甚至动作按钮也消失了。

I am implementing custom push notifications. I have a custom layout, modified using RemoteViews. I have set color using

        contentView.setInt(R.id.parentLayout, "setBackgroundColor", Color.parseColor("#4979C5"))

        notifBuilder.setColor(Color.parseColor("#4979C5"))
       .setColorized(true)

But it doesn't set color completely on background. I want it to have like this Android system notification

enter image description here

but I am getting this

enter image description here

Here is the styling that I have used:

notifBuilder.setColorized(true)
                .setColor(Color.parseColor("#4979C5"))
                .setStyle(NotificationCompat.DecoratedCustomViewStyle())
                .setContent(closedView)
                .setCustomBigContentView(contentView)
                .setSmallIcon(R.drawable.icon_tick)

I have tried using other styles and also removed the style but I get this result

enter image description here

Which seems to be fine as it does have background color set on complete notification area but now there is no details like app name, notification time, app icon and expand icon. Even action buttons are gone.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文