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

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

相关推荐
CV资深专家12 小时前
Android 各分区模块编译配置(mk/bp)总结
android
louisgeek14 小时前
Java 线程池取消的方式
android
Billy_Zuo14 小时前
人工智能机器学习——模型评价及优化
android·人工智能·机器学习
tangweiguo0305198715 小时前
Flutter与原生混合开发:实现完美的暗夜模式同步方案
android·flutter
雨白16 小时前
深入理解 Android 触摸事件:以实现 ViewPager 为例
android
shenshizhong16 小时前
看懂鸿蒙系统源码 比较重要的知识点
android·harmonyos
一只修仙的猿18 小时前
再谈性能优化,一次项目优化经历分享
android·性能优化
雮尘19 小时前
Android性能优化之枚举替代
android
2501_9159090621 小时前
苹果上架App软件全流程指南:iOS 应用发布步骤、App Store 上架流程、uni-app 打包上传与审核技巧详解
android·ios·小程序·https·uni-app·iphone·webview
2501_9159214321 小时前
iOS 文件管理与能耗调试结合实战 如何查看缓存文件、优化电池消耗、分析App使用记录(uni-app开发与性能优化必备指南)
android·ios·缓存·小程序·uni-app·iphone·webview