当我的应用程序加载时,它会经历 3 个阶段,我正试图弄清楚如何使它们保持一致。
我试图让所有这三个成为最后一个(白色标题),但我无法让它工作(尤其是灰色条)
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="LaunchTheme" parent="@android:style/Theme.Black.NoTitleBar">
<item name="android:windowBackground">@drawable/launch_background</item>
<!-- <item name="android:windowLightStatusBar">true</item> -->
<!-- <item name="android:windowDrawsSystemBarBackgrounds">true</item> -->
<!-- <item name="android:statusBarColor">@android:color/transparent</item> -->
</style>
</resources>
Run Code Online (Sandbox Code Playgroud)
无论 statusBarColor 是什么,条形开始为黑色
windowLightStatusBar 将图标变成黑色(感觉像是在进步)
windowDrawSystemBarBackgrounds 确实将栏更改为白色,但是居中的图像向下移动(我想这是有道理的,应用程序不负责该空间?)
如果我使用上述选项,当它从第一阶段切换到第二阶段时,灰色标题仍会出现并且居中的图像会移动。
我目前不知道如何修复灰色标题。
Launch_background.xml
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@android:color/white" />
<!-- You can insert your own image assets here -->
<item>
<bitmap
android:gravity="center"
android:src="@drawable/logo" />
</item>
</layer-list>
Run Code Online (Sandbox Code Playgroud)
安卓清单
<activity
android:name=".MainActivity"
android:launchMode="singleTop"
android:theme="@style/LaunchTheme"
android:windowSoftInputMode="adjustResize">
<!-- This keeps the window background of the activity showing
until Flutter renders its first frame. It can be removed if
there is no splash screen (such as the default splash screen
defined in @style/LaunchTheme). -->
<meta-data
android:name="io.flutter.app.android.SplashScreenUntilFirstFrame"
android:value="true" />
Run Code Online (Sandbox Code Playgroud)
在 Flutter 中,我认为我有
SystemChrome.setSystemUIOverlayStyle(
SystemUiOverlayStyle(
statusBarColor: Colors.transparent,
statusBarIconBrightness: Brightness.dark,
statusBarBrightness: Brightness.dark,
),
);
Run Code Online (Sandbox Code Playgroud)
小智 5
其实是flutter引擎的一个bug, https://github.com/flutter/flutter/issues/64001
Flutter 对那个灰色状态栏进行了硬编码,这很愚蠢而且很难找到。甚至浪费了几个小时来定位这个错误。
解决方法是这样的
public class MainActivity extends FlutterActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//https://github.com/flutter/flutter/issues/64001
Window window = getWindow();
window.setStatusBarColor(0x00000000);
window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
}
Run Code Online (Sandbox Code Playgroud)
}
然后您可以设置自己的颜色和样式!
| 归档时间: |
|
| 查看次数: |
632 次 |
| 最近记录: |