【发布时间】:2020-12-22 09:00:16
【问题描述】:
当 Android 设备设置为暗模式时。 但用户只想在这个应用程序上看到 Light 模式。 有没有办法处理这个问题?
此代码不适用于我
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO)
这些代码都不起作用
val config: Configuration = resources.getConfiguration()
config.uiMode = Configuration.UI_MODE_NIGHT_NO
resources.configuration.uiMode= Configuration.UI_MODE_NIGHT_NO
applicationContext.createConfigurationContext(config)
resources.updateConfiguration(config, getResources().getDisplayMetrics())
【问题讨论】:
-
你可以看看这个answer
-
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO) 对我不起作用
标签: android material-design android-darkmode