gpt4 book ai didi

android - Notification Builder setSmallIcon "background"颜色

转载 作者:行者123 更新时间:2023-11-29 19:43:47 25 4
gpt4 key购买 nike

我正在处理通知。我会使用下面的代码设置通知图标,但无法设置图标的背景颜色(突出显示的圆形紫色)。如果有人愿意分享这个方法,那就太好了。

    notificationBuilder.setContentTitle(title);
notificationBuilder.setContentText(summaryText);
notificationBuilder.setSmallIcon(R.drawable.icon);
notificationBuilder.setContentIntent(clickIntent);
notificationBuilder.setDeleteIntent(deleteIntent);

enter image description here

[后续]嗯……我已经尝试了帖子中建议的方法,但是……图标的背景颜色仍然是“白色”......我不会设置颜色...

enter image description here

最佳答案

You can probably create drawable to set icon background and set that as icon 

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:right="@dimen/margin_10dp" android:left="@dimen/margin_10dp" android:top="@dimen/margin_10dp" android:bottom="@dimen/margin_10dp">
<shape android:shape="rectangle">
<solid android:color="@color/purple"/>
<padding android:bottom="@dimen/margin_10dp" android:right="@dimen/margin_10dp" android:left="@dimen/margin_10dp" android:top="@dimen/margin_10dp"/>
</shape>
</item>
<item android:drawable="@mipmap/logo" >
</item>

</layer-list>

关于android - Notification Builder setSmallIcon "background"颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38200483/

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