当前位置:网站首页>Notification设置的小图标显示的是小方块
Notification设置的小图标显示的是小方块
2022-07-25 22:53:00 【锐湃】
方法一 (修改图标的尺寸和大小) (无效):
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.abc)
.setContentTitle("aaaaa")
.setContentText("bbbbbb")
.setLargeIcon(abcd);调用了setSmallIcon()方法,但是通知栏显示时的小图标是个方块,不是我们设置的图标;
解决:图标大小限制在20kb以内。 (无效)
排查技巧:
设置的图标过大时,AndroidStudio预览时图片显示不出来;

换成小图标就可以正常显示了:

这个电话的小图标能显示,但是是灰色的,不是彩色的。(没有完全解决)

方法二(有效):
在不同的版本使用不同的图标,在android 8.0以下,使用透明背景的图标,配上底色。
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
builder.setSmallIcon(R.mipmap.launcher_icon);
} else {
// 背景透明的图片,配上底色
builder.setSmallIcon(R.mipmap.icon_notification)
.setColor(Color.parseColor("#0972EE"));
}————————————————
版权声明:本文为CSDN博主「唐诺」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/zhijiandedaima/article/details/125007616
边栏推荐
- 汇编语言与微机原理实验一、实验二、实验三:分支程序设计/循环程序设计/子程序设计
- What are the differences between FileInputStream and bufferedinputstream?
- What is the difference between bio, NiO and AIO?
- We media people must have four resource tools, each of which is very practical
- 技术美术百人计划学习笔记(2)--向量
- 依法严厉打击违规自媒体运营者:净化自媒体行业迫在眉睫
- [training Day12] be go! [dynamic programming] [mathematics]
- JSON object
- Oracle query statement summary
- Network Security Learning (XIII) data link layer
猜你喜欢

Hcie is finally in hand, and the road begins

CMU AI PhD first year summary

QVariant的使用
![[training Day12] tree! Tree! Tree! [greed] [minimum spanning tree]](/img/46/1c7f6abc74e11c4c2e09655aade223.png)
[training Day12] tree! Tree! Tree! [greed] [minimum spanning tree]

invalid syntax
![[literature reading] - HRL -[hrl with universal policies for multi step robotic control]](/img/34/06d5ba3af4e6e775a335324c020161.png)
[literature reading] - HRL -[hrl with universal policies for multi step robotic control]

【自然语言处理】【向量表示】AugSBERT:改善用于成对句子评分任务的Bi-Encoders的数据增强方法
![[PMP learning notes] Chapter 1 Introduction to PMP System](/img/80/144124af40f0a015c4deafc3aa7432.png)
[PMP learning notes] Chapter 1 Introduction to PMP System

recyclerview计算滑动距离之computeHorizontalScrollExtent-computeHorizontalScrollRange-computeHorizontalScrol

内存分页与调优,内核与用户空间
随机推荐
Experiment 1, experiment 2 and Experiment 3 of assembly language and microcomputer principle: branch program design / loop program design / subroutine design
依法严厉打击违规自媒体运营者:净化自媒体行业迫在眉睫
内存分页与调优,内核与用户空间
CUDA environment construction
[tensorflow] about seed
Ip--- ia review
技术美术百人计划学习笔记(1)--基础渲染管线
Day006 select structure (if statement exercise)
Select structure if branch structure
Short circuit and &, short circuit or |, logic and &, logic or |; Conditional operator
TFrecord写入与读取
Vodak software: Smart City solution
[natural language processing] [vector representation] augsbert: improve the data enhancement method of Bi encoders for paired sentence scoring tasks
[training day15] paint road [minimum spanning tree]
721. Account consolidation ●●, and collection
Today, I sorted out some problems about high collapse
【论文笔记】基于在线预测和规划的机器人动态跟踪抓取方法
Severely crack down on illegal we media operators according to law: it is urgent to purify the we media industry
单元测试,写起来到底有多痛?
冯诺依曼体系结构