这位怪蜀黍 早上好,早起的鸟儿有虫吃噢!早起的虫儿被鸟吃,你是鸟儿还是虫儿?嘻嘻!

Flutter 碎知识(一) 设置启动页

Posted on   WALL*E  阅读(945)  评论(0编辑  收藏  举报

一、在main入口配置

void main() async{
  // SystemChrome.setEnabledSystemUIOverlays([]);//隐藏状态栏,底部按钮栏
  // SystemChrome.setEnabledSystemUIOverlays([SystemUiOverlay.bottom]);//隐藏状态栏,保留底部按钮栏
  // SystemChrome.setEnabledSystemUIOverlays(SystemUiOverlay.values);//显示状态栏、底部按钮栏

  SystemChrome.setSystemUIOverlayStyle(const SystemUiOverlayStyle( //设置状态栏透明
    statusBarColor: Colors.transparent,
    statusBarIconBrightness: Brightness.dark,
  ));

  WidgetsBinding widgetsBinding = WidgetsFlutterBinding.ensureInitialized();//设置启动页
  FlutterNativeSplash.preserve(widgetsBinding: widgetsBinding);

  await SystemChrome.setPreferredOrientations([ DeviceOrientation.portraitUp] );
  runApp(const MyApp());
}

二、在 项目名\android\app\src\main\res\drawable\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/white" />-->
    <item>
        <bitmap android:gravity="fill" android:src="@drawable/background"/>
    </item>
    <!-- You can insert your own image assets here 自己项目的图片 -->
    <item>
        <bitmap
            android:gravity="center"
            android:src="@drawable/splash" />
    </item>
</layer-list>

个人使用,仅供参考。

相关博文:
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
· AI与.NET技术实操系列(六):基于图像分类模型对图像进行分类
点击右上角即可分享
微信分享提示