我是 Flutter 新手,仍在练习中
我正在创建一个启动屏幕,但启动屏幕的颜色没有改变
My Code:
-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")),
);
}
}
It should ho black screen but it still white screen
SS:
![enter image description here](https://i.stack.imgur.com/wUkOW.png)
你还需要改变launch_background.xml
的文件drawable-v21
文件夹与drawable
folder.
Change
<item android:drawable="?android:colorBackground" />
你所做的调整@android:color/black
(or @color/backgroudColor
对于自定义的colors.xml
file);
<item android:drawable="@color/backgroudColor" />
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)