Reputation: 738
i have a Notification with a custom XML-Layout, therefore i can't use default Styles like MessagingStyle or MediaStyle.
The problem is, that the Notification Stays white, even if Dark Mode is on, which is quite annoying.
I checked the Source Code of MessagingStyle and MediaStyle, it seems that the Dark Mode BackgroundColor is set by the Statusbar itself, when using these Styles, they can not be extracted from the Notification Object itself (not even with Reflections)
Is it possible to retrieve the background color somehow?
I think it would not be a good practice to hardcode the color, it might be different on different Smartphones...
Edit: even settings correct colors does not help... Notification are light in lockscreen and dark in notification bar...
Upvotes: 4
Views: 4983
Reputation: 738
it seems to be a Samsung Problem:
on Stock Android Notifications are white, even if Dark Mode is used, so nothing to do here.
On Samsung Devices Notifications are also dark, but still white in Lockscreen, so if you set a background color, it will be "wrong" in either the lockscreen or the notification bar (you could always show/cancel a different notification in locked/unlocked state, what is not really a nice solution)
Anyway, there is a way to get the correct background color for Samsung Devices: On https://stackoverflow.com/a/7320604/1988378 it is explained, how to get the default textcolor. Samsung inverts the background, so that the background in dark mode is the text color in light mode.
Upvotes: 3