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

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

相关推荐
凛_Lin~~14 分钟前
安卓网络框架——OkHttp源码解析(基于3.14.x)
android·网络·okhttp
stevenzqzq38 分钟前
android SharedFlow和Channel比较
android·channel·sharedflow
zhangphil1 小时前
Kotlin实现Glide/Coil图/视频加载框架(二)
android·kotlin
shughui1 小时前
APP、Web、H5、iOS与Android的区别及关系
android·前端·ios
千里马学框架2 小时前
敏感权限如何自动授权?pkms的permission部分常用命令汇总
android·车载系统·framework·perfetto·权限·系统开发·pkms
a2591748032-随心所记2 小时前
android14 google默认进程、apk、hal、以及service等
android
明天…ling2 小时前
四天学习笔记
android
小六花s2 小时前
渗透测试前四天PHP文件包含笔记
android·学习·渗透测试
Rubin智造社3 小时前
见路不走:从《天幕红尘》读懂2026年的创新密码
android·开发语言·kotlin
冷雨夜中漫步3 小时前
Python入门——__init__.py文件作用
android·java·python