【发布时间】:2018-08-17 03:56:40
【问题描述】:
正如标题所示,这是关于 Flutter 的。
有没有什么办法可以将Android状态栏切换到浅色模式,让状态栏中的图标显示为暗色?以图片为例。
我尝试了以下可能的解决方案,但都没有奏效 -
// main.dart
appBar: new AppBar(
brightness: Brightness.light,
backgroundColor: Colors.white,
),
// MainActivity.kt
// Following 2 lines do change the color of status and nav bars
window.statusBarColor = 0x00000000
window.navigationBarColor = 0x00000000
// This seems to have no effect. Icons are still white.
window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
更新
对此的支持正在进行中 - https://github.com/flutter/flutter/issues/17231
【问题讨论】:
-
您使用 AndroidManifest 执行此操作,而不是使用 dart 代码
-
如何在 AndroidManifest 中做到这一点?此外,被标记为可能重复的问题是关于状态栏颜色的。这个问题与状态栏颜色无关。请注意
<item name="android:windowLightStatusBar">true</item>不同于<item name="android:statusBarColor">@color/whatever</item> -
我可以从 Dart 更改状态栏颜色。很有可能将其设置为来自 Dart 的默认较暗版本的 appbar 颜色。但我无法将其更改为浅色,因此其中的图标是深色的。