I am implementing custom push notifications. I have a custom layout, modified using RemoteViews. I have set color using
contentView.setInt(R.id.parentLayout, "setBackgroundColor", Color.parseColor("#4979C5"))
notifBuilder.setColor(Color.parseColor("#4979C5"))
.setColorized(true)
But it doesn't set color completely on background. I want it to have like this Android system notification
but I am getting this
Here is the styling that I have used:
notifBuilder.setColorized(true)
.setColor(Color.parseColor("#4979C5"))
.setStyle(NotificationCompat.DecoratedCustomViewStyle())
.setContent(closedView)
.setCustomBigContentView(contentView)
.setSmallIcon(R.drawable.icon_tick)
I have tried using other styles and also removed the style but I get this result
Which seems to be fine as it does have background color set on complete notification area but now there is no details like app name, notification time, app icon and expand icon. Even action buttons are gone.
Related
I want to achieve something like Myntra App Notifications where i can change the background color of my notification in Android 12
Since Android 12 have restricted custom notifications how can we set the color for whole notification?
You can't directly customize Push notifications. What you can do is override onMessageReceived() in your service that extends FireBaseMessagingService, and then create a local custom notification with whatever background color you want.
Edit: If you're asking how to apply a background color to local notifications, you need to set both of the following in the Notification Builder:
.setColor(resources.getColor(R.color.yourBgColor))
.setColorized(true)
and if that doesn't work for some reason, you'll need to create a custom notification layout in XML with the background color you want, and then
.setCustomContentView(notificationView)
I have already tried with transparent background, it's working fine but I need more than 1 color in the notification small icon.
When I am trying to get results find whatever color we use that will change by icon color what we give in our code only transparent color is always transparent.
I have tried custom layout notifications but I got stuck with android 11 some devices work fine but some devices show a grey square icon.
I want a notification icon with multi-color in the status bar and when we expand notifications.
As of android V5.0.0 i.e target sdk version 21, android will always tint your notification icon on the status bar. On Scrolling down the notifications on your lock screen in the newer version you can show a custom icon that can be of any color but on the status bar you wont be able to show multi color icons.
I change the top color of the icon and the app name by using setColor method of the NotificationCompat.Builder, The problem is that the displayed color doesn't match the provided one as it gets darker in the notification.
my color is #21bbe6
I did find out Android N notification title and icon color is darker, but I still don't understand why, and how to deal with it.
https://imgur.com/a/6nx4EsA
Google decided to restrict acceptable colors in Notification when using setColor.
It's undocumented!
Android Oreo has option to show notification dot for any new push notification. However, it is not documented anywhere whether it is possible to change the color of Notification dot programatically.
Any suggestions?
It seems that this color is taken based on app colors icon - probabbly most frequently used color.
I am using Notification.Builder to create a notification. For this notification I am using a level-list as the small Icon
mNotificationBuilder.setSmallIcon(R.drawable.icon_levellist, levelInt);
This sets the icon to the correct level in the status bar, however when pulling down the notification the icon is set to the default level.
I have tried using a custom layout in order to display this and it works, however I would like to be able to use the default layout that comes with Notification.Builder.
Is this a bug?
I think it is a bug as I am experiencing the same thing
You can star this issue:
http://code.google.com/p/android/issues/detail?id=43179&q=setSmallIcon&colspec=ID%20Type%20Status%20Owner%20Summary%20Stars