Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is ?android:attr/textColorPrimary black in night mode notification?

I'm trying to implement night mode for my app.

In my whole app, ?android:attr/textColorPrimary is white in night mode and black in day mode. Just in my notifications it's always black. In the Android Studio layout preview the text is white. (I'm sending the notifications from a foreground service if that's relevant.)

I could make a night mode layout file for the notifications where I use @color/white for the text but why doesn't it work with attributes?


1 Answers

I've found the reason. I had to set the notification layout's theme to Theme.MaterialComponents.DayNight.