【问题标题】:Flutter, Android - Is it possible to change status bar color on splash (launch) screen?Flutter,Android - 是否可以在启动(启动)屏幕上更改状态栏颜色?
【发布时间】:2020-11-14 03:56:57
【问题描述】:

我正在尝试在 Flutter for Android 中更改启动画面上的状态栏颜色。但是,无论我做什么,它的颜色都保持不变(黑色)。我已经尝试在 Android styles.xml 中设置 colorPrimaryDark、statusBarColor 和其他内容。有可能吗?

【问题讨论】:

    标签: android flutter splash-screen android-statusbar


    【解决方案1】:
     <style name="SplashTheme" parent="Theme.AppCompat.NoActionBar">
        <item name="android:windowBackground">@drawable/background</item>
        <item name="android:windowDrawsSystemBarBackgrounds">true</item>
        <item name="android:statusBarColor">@android:color/transparent</item>
        <item name="android:windowTranslucentNavigation">true</item>
    </style>
    

    【讨论】:

    • 这就是我需要的!谢谢
    • 嗨@season,再次感谢您的帮助。我遇到了另一个问题,也许你知道如何解决它。应用 NormalTheme 或 SplashScreenDrawable 时 - 状态栏有一些覆盖 - prnt.sc/tnt6sb Dart 代码初始化后立即恢复正常
    • AppCompat 在 build.gradle 的依赖部分中需要 implementation 'com.android.support:appcompat-v7:27.1.1'。但是如上所述,这仅适用于启动屏幕。 Flutter 进程一开始,NormalTheme 就会生效,状态栏会变成深透明色。出于某种原因,io.flutter.embedding.android.NormalTheme 似乎完全覆盖或忽略了大多数样式,包括 statusBarColor,这是该解决方案未解决的问题。
    • @parkgrrr 经过一番钻研后,我发现这是一个更深层次的问题,无法完全解决 :(。您可能需要查看以下 GitHub 问题 (github.com/flutter/flutter/issues/64001 ) 虽然它在今天可能并不完全适用。
    • 感谢您的解决方案,为我工作:我使用 parent="@android:style/Theme.Black.NoTitleBar" 并且一切正常。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-11-05
    • 1970-01-01
    • 2015-05-09
    • 2016-01-20
    • 2020-10-23
    • 2021-06-05
    • 1970-01-01
    相关资源
    最近更新 更多