带有configChanges的Android DayNight主题 [英] Android DayNight Theme with configChanges
问题描述
我正在创建一个使用Android支持库的主题DayNight的应用程序.
I'm creating an app where I use the theme DayNight of the Android support libraries.
这是themes.xml中的代码
This is the code in themes.xml
<style name="ActivityTheme" parent="Theme.AppCompat.DayNight.NoActionBar">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
我在清单中使用configChanges来管理轮换.
I use configChanges in the manifest to manage rotations.
android:configChanges="keyboardHidden|orientation|screenSize"
在我的AppcompatActivity的onCreate中,我添加了:
In the onCreate on my AppcompatActivity I have added:
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES)
问题是,当我使用setDefaultNightMode时,android:configChanges停止工作,并在每次旋转中重新创建活动.
The problem is that when I use setDefaultNightMode, android:configChanges stops working, and recreate de activity in every rotation.
任何形式的帮助都将受到欢迎
Any kind of help will be welcome
推荐答案
Seems to be a bug and will be fixed in AppCompat v.1.1.0 according to this issue.
在修复之前,我会像在此处
Until its fixed I would add the uiMode
flag to android:configChanges
like mentioned here
这篇关于带有configChanges的Android DayNight主题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!