I'm having an issue with the color of my custom notification background in Lollipop. It's black where it should be white. The textColor is OK:
I'm using
<resources>
<style name="NotificationText" parent="android:TextAppearance.StatusBar.EventContent" />
<style name="NotificationTitle" parent="android:TextAppearance.StatusBar.EventContent.Title" />
</resources>
Any idea how to use the device default theme color for custom notification ?
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()
Changing background colour of a notification is possible with the version Oreo. It is used with the method ‘setColorized (Boolean)’. This flag is false by default.
Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project. Step 2 − Add the following code to res/layout/activity_main.xml. Step 3 − Add the following code to res/layout/custom_notification_layout.xml.
monochrome: a photograph or picture developed or executed in black and white or in varying tones of only one colour. The material.io page states that the icon of the notification in the status bar cannot have a colour. You have just 2 options; Have a look at this nice q/a. What about ‘setSmallIcon’?
To ensure your notification looks its best across different versions of Android, you should always use the standard notification template to build your notification. However, if the system templates do not meet your needs, you can provide your own layout for the notification.
Your app's targetSdkVersion must be 21.
As Ahmed's answere, add another styles file in values-21 folder.
<?xml version="1.0" encoding="UTF-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="NotificationText" parent="android:TextAppearance.Material.Notification" />
<style name="NotificationTitle" parent="android:TextAppearance.Material.Notification.Title" />
<style name="NotificationTime" parent="android:TextAppearance.Material.Notification.Time" />
</resources>
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