状态栏会显示一个白底的方框;下拉通知栏展开时的图标为白底方框加圆框,不展开时为黑底方框。
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图标;
小图标背景色要透明,然后用纯白勾勒出你需要的图标(用任意颜色都会表现为白色)。