Android状态栏/通知栏图标白底问题

状态栏会显示一个白底的方框;下拉通知栏展开时的图标为白底方框加圆框,不展开时为黑底方框。

vendor/mediatek/proprietary/packages/apps/SystemUI/src/com/android/systemui/statusbar/phone/NotificationIconAreaController.java

private void updateTintForIcon(StatusBarIconView v, int tint) {

boolean isPreL = Boolean.TRUE.equals(v.getTag(R.id.icon_is_pre_L));

int color = StatusBarIconView.NO_COLOR;

//*/not replace color,def no color

boolean colorize = false;

/*/
boolean colorize = !isPreL || NotificationUtils.isGrayscale(v, mContrastColorUtil);

//*/

if (colorize) {

color = DarkIconDispatcher.getTint(mTintArea, v, tint);

}

v.setStaticDrawableColor(color);

v.setDecorColor(tint);

}

frameworks/base/core/java/android/app/Notification.java

private void processSmallIconColor(Icon smallIcon, RemoteViews contentView,

StandardTemplateParams p) {

//*/def use no color

boolean colorable = false;

/*/
boolean colorable = !isLegacy() || getColorUtil().isGrayscaleIcon(mContext, smallIcon);

//*/

int color;

if (isColorized(p)) {

color = getPrimaryTextColor(p);

} else {

color = resolveContrastColor(p);

}

if (colorable) {

contentView.setDrawableTint(R.id.icon, false, color,

PorterDuff.Mode.SRC_ATOP);

}

contentView.setInt(R.id.notification_header, "setOriginalIconColor",

colorable ? color : NotificationHeaderView.NO_COLOR);

}

单独应用通知设置:

NotificationManager notificationManager= (NotificationManager) getSystemService(NOTIFICATION_SERVICE);

NotificationCompat.Builder builder=new NotificationCompat.Builder(this);

Notification notification=builder.setContentTitle(getString(R.string.notification_title))

.setContentText(getString(R.string.notification_content)).setWhen(System.currentTimeMillis())

.setDefaults(Notification.DEFAULT_LIGHTS).setSmallIcon(R.mipmap.icon_weixin)

.setColor(Color.parseColor("#880000FF"))

.setLargeIcon(BitmapFactory.decodeResource(getResources(),R.mipmap.weixin_raw))

.setContentIntent(PendingIntent.getActivities(this,0x0001,new Intent\[\]{new Intent(this,MainActivity.class)},PendingIntent.FLAG_UPDATE_CURRENT))

.build();

notificationManager.notify(1,notification);

大图标是应用logo图标;

小图标背景色要透明,然后用纯白勾勒出你需要的图标(用任意颜色都会表现为白色)。

相关推荐
ha_lydms12 分钟前
AnalyticDB分区、分布键性能优化
android·大数据·分布式·性能优化·分布式计算·分区·analyticdb
星辰24 分钟前
Ijkplayer重新编译支持h264裸流
android
测试开发-学习笔记1 小时前
Android studio安装
android·ide·android studio
宋拾壹1 小时前
同时添加多个类目
android·开发语言·javascript
●VON2 小时前
AtomGit Flutter鸿蒙客户端:数据模型
android·服务器·安全·flutter·harmonyos·鸿蒙
火柴就是我2 小时前
记录一个文本随手指缩放的功能
android
Zender Han3 小时前
Android APK 签名 v1、v2、v3、v4 有什么区别?
android
神仙别闹3 小时前
基于 PHP + MySQL学生信息管理系统
android·mysql·php
墨狂之逸才4 小时前
Android 保活机制详解 —— 从概念到实践
android
故渊at4 小时前
第二板块:Android 四大组件标准化学理 | 第十二篇:四大组件全景总结与系统服务(System Server)架构
android·架构·wpf·四大组件·system service