我正在创建一个应用程序,我使用Android支持库的主题DayNight。
这是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来管理轮换。
android:configChanges="keyboardHidden|orientation|screenSize"
在我的AppcompatActivity上的onCreate中,我添加了:
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES)
问题是当我使用setDefaultNightMode时,android:configChanges停止工作,并在每次轮换中重新创建de活动。
欢迎任何形式的帮助