I was going through the Notifications design pattern, and didn't find anything that talks about notification icon background. As you probably noticed, there is only a light grey background for custom notifications. But apps like Hangouts, or simply the USB Debugging notification has a custom color for their notification icon background.
Is there any possibility to change that grey into something else? (that specific circle's color programmatically)
call setColor -> the color to be used on the background. call setColorized -> the actual call to set the background color. set style to NotificationCompat. DecoratedMediaCustomViewStyle()
Step 1: After opening the android studio and creating a new project with an empty activity. Step 2: Navigate to res/values/colors. xml, and add a color that you want to change for the status bar.
From the main settings menu, "Notification Theme" allows you to change the background color of your notifications. You can enable a dark theme, light theme, the system default, or choose from a selection of colors.
int color = 0xff123456; int color = getResources().getColor(R.color.my_notif_color); int color = ContextCompat.getColor(context, R.color.my_notif_color);
NotificationCompat.Builder builder = new NotificationCompat.Builder(this); ... builder.setColor(color); Notification notif = builder.build();
The color is respected only on Lollipop and only affects background of the small icon. If a large icon is shown its contents are entirely your responsibility.
Source: NotificationCompat.Builder#setColor(int)
if you've defined color in colors.xml then in your NotificationBuilder add value as
.setColor(getResources().getColor(R.color.<YOUR_COLOR>))
That should solve your problem. It only affect to background of the icon.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With