gpt4 book ai didi

flutter - 闪屏颜色在 flutter 中没有改变

转载 作者:行者123 更新时间:2023-12-05 03:41:12 28 4
gpt4 key购买 nike

我是 Flutter 新手,还在练习

我正在创建启动画面,但启动画面的颜色没有改变

我的代码:

-launch_background.xml

<?xml version="1.0" encoding="utf-8"?>
<!-- Modify this file to customize your launch splash screen -->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@android:color/black" />

<!-- You can insert your own image assets here -->
<!-- <item>
<bitmap
android:gravity="center"
android:src="@mipmap/launch_image" />
</item> -->
</layer-list>

-main.dart

import 'package:flutter/material.dart';
import 'package:id_locker/Screens/HomeScreen.dart';

void main() {
runApp(MyApp());
}

class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: HomeScreen(),
);
}
}

-HomeScreen.dart

import 'package:flutter/material.dart';
import 'package:hexcolor/hexcolor.dart';

class HomeScreen extends StatefulWidget {
const HomeScreen({Key? key}) : super(key: key);

@override
_HomeScreenState createState() => _HomeScreenState();
}

class _HomeScreenState extends State<HomeScreen> {
@override
Widget build(BuildContext context) {
return Container(
decoration: BoxDecoration(color: HexColor("#2301FA")),
);
}
}

应该是黑屏,但还是白屏党卫军: enter image description here

最佳答案

您还需要更改 drawable-v21 文件夹的 launch_background.xml 文件,与 drawable 文件夹相同。

改变

<item android:drawable="?android:colorBackground" />

您对 @android:color/black 所做的调整(或 @color/backgroudColor 用于自定义 colors.xml 文件);

<item android:drawable="@color/backgroudColor" />

关于flutter - 闪屏颜色在 flutter 中没有改变,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67859371/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com