【问题标题】:How to avoid restarting activity on orientation change in DayNight mode?如何避免在 DayNight 模式下重新启动更改方向的活动?
【发布时间】:2019-03-15 06:55:02
【问题描述】:

我正在我的应用程序中尝试daynight mode。我的问题是,活动正在根据方向变化重新创建。它适用于 AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO) 。但是当我将 nightmode 设置为 AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES) 并改变方向时,它会导致 活动重启。我在AndroidManifest.xml 文件中尝试了android:configChanges="keyboardHidden|orientation|screenSize|smallestScreenSize|screenLayout"。但没有帮助。现在我的问题是,如何避免使用AppCompatDelegate.MODE_NIGHT_YES 重新启动有关方向更改的活动。对不起我的英语不好。任何帮助将不胜感激。谢谢。

【问题讨论】:

    标签: android orientation activity-lifecycle


    【解决方案1】:

    我回答了类似的问题here

    总结

    • 这是一个错误,将在 AppCompat v1.1.0 中修复(自 v1.1.0-alpha03 起已修复)。
    • 在修复之前,我会将uiMode-标志添加到android:configChanges

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-03-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-06-02
      • 1970-01-01
      • 2016-07-14
      相关资源
      最近更新 更多