我有AndriodManifest.xml
,其值如下:
<meta-data
android:name="com.google.firebase.messaging.default_notification_icon"
android:resource="@drawable/ic_stat_notification" />
<meta-data
android:name="com.google.firebase.messaging.default_notification_color"
android:resource="@color/defaultNotificationColor"/>
然后我在两个文件夹中有colors.xml
——values/colors.xml
和values-night/colors.xml
。我用覆盖values-night
内的defaultNotificationColor
<resources>
<color name="defaultNotificationColor">#ffffff</color>
</resources>
但此设置被忽略,并且通知的颜色是来自values/colors.xml
的颜色。
从以下代码访问时,该值设置正确:
resources.getString(R.color.defaultNotificationColor) // this is OK
是否可以为清单中的图标上色?
SDK设置:
compileSdkVersion = 29
targetSdkVersion = 29
minSdkVersion = 19
我认为这就是自动暗模式在Android 10及以上上的工作方式
只有当您的应用程序使用深色模式时,才会使用values-night/colors.xml
下的颜色字符串(使用AppCompatDelegate.getDefaultNightMode
检查浅色和深色模式分别为MODE_NIGHT_NO
或MODE_NIGHT_YES
(。
如果它不在暗模式下,它将继续使用values/colors.xml
下的颜色字符串,这就是在您的中发生的情况
你也可以在这里检查你是否支持Android 10及以上版本的默认夜间主题