android - 带有 configChanges 的 Android DayNight 主题
问题描述
我正在创建一个应用程序,在其中使用 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 停止工作,并在每次轮换中重新创建活动。
欢迎任何形式的帮助
解决方案
推荐阅读
- excel - “Excel.Application”中的“Excel”是指对象吗?如果不是,它指的是什么?
- date - awk 似乎计算错误的日期
- javascript - 尝试使用 setTimeout 延迟逐个字符写入
- tomcat8 - Apache Guacamole Web 客户端未显示任何连接
- javascript - 将 3rd 方脚本对象嵌入到 React 组件中
- python - 使用熊猫切片和连接?
- mysql - 逗号分隔列表中的 MySQL 更新顺序(行号) - 最简单的方法
- python - 搜索连续素数时变量未正确更新
- python - 使用自定义标准进行前向特征选择
- angular - Angular 下载需要很长时间才能显示下载链接