【发布时间】:2021-12-07 17:22:27
【问题描述】:
我正在创建一个应用,其中使用 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 停止工作,并在每次轮换中重新创建活动。
欢迎任何形式的帮助
【问题讨论】:
标签: android rotation orientation