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图标;

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

相关推荐
solo_995 小时前
用 LSPosed 模拟录屏音频编码器卡顿:从思路到落地
android
zzq77975 小时前
别把大模型 API Key 写进 APK:移动 AI 应用接口防盗刷实践
android·人工智能·安全·app加固·御盾安全·安卓加固
xiaopang7 小时前
RK3568 AOSP 编译与快速部署实战
android
码农coding8 小时前
android12 SystemUI之通知
android
summerkissyou19878 小时前
android - 性能 - Perfetto - cpu 分析教程及例子
android·性能
AFinalStone10 小时前
Android 7系统休眠唤醒(七)内核层—wakelock与autosleep机制
android·休眠唤醒
starvapour10 小时前
在关机键损坏的情况下让手机关机
android·adb·手机
AFinalStone11 小时前
Android 7系统休眠唤醒(八)内核层—Alarm定时唤醒与硬件唤醒源
android·电源管理·休眠唤醒
AFinalStone11 小时前
Android 7系统休眠唤醒(五)休眠全链路
android·电源管理·休眠唤醒