这是我在attr_styles.xml中的风格
<style name="AttrStyles" parent="Theme.AppCompat.DayNight.NoActionBar">
<item name="calendarAppointmentView">@style/calendar_appointment_view</item>
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="alertDialogTheme">@style/white_style</item>
</style>我有两个colors.xml文件。1表示值,另一个表示值-夜。
如果我从手机设置中选择DarkMode on或off,它就能正常工作。但我想在我的应用程序中有一个微调,有:自动,开,关。如何基于该微调器强制它显示浅色(值)或显示深色(值-夜)?
我尝试在我的App.kt类(应用程序类)中调用onCreate()如下:
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES)或
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO)但是什么也没发生。我做错了什么?
发布于 2020-01-23 22:03:34
在搜索你的问题大约2分钟后,我遇到了一个类似的问题,几乎有answer you're looking for。看起来你必须使用setTheme方法。
https://stackoverflow.com/questions/59880224
复制相似问题