Dart 如何使设备顶部面板(状态栏)与颤振中的AppBar具有相同的背景颜色?
如何使设备顶部面板(状态栏)与颤振中的AppBar具有相同的背景颜色?设备顶部面板的颜色始终比AppBar backgroundColor暗。非常感谢。在iOS上,这已经是事实了 在Android上,在调用Dart 如何使设备顶部面板(状态栏)与颤振中的AppBar具有相同的背景颜色?,dart,flutter,Dart,Flutter,如何使设备顶部面板(状态栏)与颤振中的AppBar具有相同的背景颜色?设备顶部面板的颜色始终比AppBar backgroundColor暗。非常感谢。在iOS上,这已经是事实了 在Android上,在调用super.onCreate(savedInstanceState)之后,将以下内容添加到MainActivity.java中的onCreate 这将覆盖默认状态栏颜色0x40000000,该颜色是在flatterActivityDelegate方法中设置的 这里是一个特定于颤振的解决方案。在
super.onCreate(savedInstanceState)之后,将以下内容添加到MainActivity.java
中的onCreate
代码>
这将覆盖默认状态栏颜色0x40000000
,该颜色是在flatterActivityDelegate
方法中设置的
这里是一个特定于颤振的解决方案。在构建方法中,可以使用颤振服务包
import 'package:flutter/services.dart';
Widget build(BuildContext context) {
SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle(
statusBarColor: Colors.transparent, //top bar color
statusBarIconBrightness: Brightness.dark, //top bar icons
systemNavigationBarColor: Colors.white, //bottom bar color
systemNavigationBarIconBrightness: Brightness.dark, //bottom bar icons
));
//....
}
非常感谢您的快速回复。它起作用了^_^有没有办法改变图标的颜色?我的appbar是白色的,以前是这样的,但现在我的文件在Kotlin中看起来像这样。如何获得透明条<代码>导入androidx.annotation.NonNull;导入io.颤振.Embedded.android.颤振活动导入io.颤振.Embedded.engine.颤振引擎导入io.颤振.plugins.GeneratedPluginRegistrant导入android.os.Build导入android.view.ViewTreeObserver导入android.view.WindowManager类主活动:颤振活动(){覆盖乐趣配置颤振引擎(@NonNull flatterengine:flatterengine){GeneratedPluginRegistrant.registerWith(flatterengine);}}}
import 'package:flutter/services.dart';
Widget build(BuildContext context) {
SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle(
statusBarColor: Colors.transparent, //top bar color
statusBarIconBrightness: Brightness.dark, //top bar icons
systemNavigationBarColor: Colors.white, //bottom bar color
systemNavigationBarIconBrightness: Brightness.dark, //bottom bar icons
));
//....
}