Android 昼夜 MODE_NIGHT_AUTO 对比 MODE_NIGHT_FOLLOW_SYSTEM
Android DayNight MODE_NIGHT_AUTO vs MODE_NIGHT_FOLLOW_SYSTEM
我读过这篇文章:https://medium.com/@chrisbanes/appcompat-v23-2-daynight-d10f90c83e94。它提到了 DayNight 主题,然后:
Then you need to enable the feature in your app. You do that by
calling AppCompatDelegate.setDefaultNightMode() which takes one of
four values:
- MODE_NIGHT_NO. Always use the day (light) theme.
- MODE_NIGHT_YES. Always use the night (dark) theme.
- MODE_NIGHT_AUTO. Changes between day/night based on the time of day.
- MODE_NIGHT_FOLLOW_SYSTEM (default). This setting follows the system’s
setting, which is essentially MODE_NIGHT_NO at the time of writing
场景很简单:
该应用程序自动切换夜间模式,无需应用程序内设置。
- 我会使用 MODE_NIGHT_AUTO 还是 MODE_NIGHT_FOLLOW_SYSTEM?
- 他们如何比较不同版本的 Android?
- 两者的优缺点是什么(我能想到应用程序之间的一致性问题...)?
我认为好的答案是:
优势
MODE_NIGHT_NO, MODE_NIGHT_YES, MODE_NIGHT_AUTO
将始终忽略 user/device 设置。您可以在您的应用中设置 nigthmode 启用,而 nigthmode 在设备上被用户完全禁用。
优势
MODE_NIGHT_FOLLOW_SYSTEM
可以等同于MODE_NIGHT_NO、MODE_NIGHT_YES、MODE_NIGHT_AUTO,用户在设备上对所有应用的用户选择。
我读过这篇文章:https://medium.com/@chrisbanes/appcompat-v23-2-daynight-d10f90c83e94。它提到了 DayNight 主题,然后:
Then you need to enable the feature in your app. You do that by calling AppCompatDelegate.setDefaultNightMode() which takes one of four values:
- MODE_NIGHT_NO. Always use the day (light) theme.
- MODE_NIGHT_YES. Always use the night (dark) theme.
- MODE_NIGHT_AUTO. Changes between day/night based on the time of day.
- MODE_NIGHT_FOLLOW_SYSTEM (default). This setting follows the system’s setting, which is essentially MODE_NIGHT_NO at the time of writing
场景很简单: 该应用程序自动切换夜间模式,无需应用程序内设置。
- 我会使用 MODE_NIGHT_AUTO 还是 MODE_NIGHT_FOLLOW_SYSTEM?
- 他们如何比较不同版本的 Android?
- 两者的优缺点是什么(我能想到应用程序之间的一致性问题...)?
我认为好的答案是:
优势
MODE_NIGHT_NO, MODE_NIGHT_YES, MODE_NIGHT_AUTO
将始终忽略 user/device 设置。您可以在您的应用中设置 nigthmode 启用,而 nigthmode 在设备上被用户完全禁用。
优势
MODE_NIGHT_FOLLOW_SYSTEM
可以等同于MODE_NIGHT_NO、MODE_NIGHT_YES、MODE_NIGHT_AUTO,用户在设备上对所有应用的用户选择。