Android icon图标、splash启动页常用尺寸

icon图标尺寸:

  • drawable-hdpi-icon 72*72
  • drawable-ldpi-icon 36*36
  • drawable-mdpi-icon 48*48
  • drawable-xhdpi-icon 96*96
  • drawable-xxhdpi-icon 144*144
  • drawable-xxxhdpi-icon 192*192

启动页:

横屏 高×宽

  • drawable-land-hdpi-screen 480*800
  • drawable-land-ldpi-screen 200*320
  • drawable-land-mdpi-screen 320*480
  • drawable-land-xhdpi-screen 720*1280
  • drawable-land-xxhdpi-screen 960*1600
  • drawable-land-xxxhdpi-screen 1280*1920

竖屏 高×宽

  • drawable-port-hdpi-screen 800*480
  • drawable-port-ldpi-screen 320*200
  • drawable-port-mdpi-screen 480*320
  • drawable-port-xhdpi-screen 1280*720
  • drawable-port-xxhdpi-screen 1600*960
  • drawable-port-xxxhdpi-screen 1920*1280

设置APP图标

  • App Icon Generator 去生成对应版本图标,并下载资源包
  • 放到项目相应目录下并替换,<project_dir>\android\app\src\main\res

设置启动图片

  • 安装包:flutter pub add flutter_native_splash

    • 方式一:在pubspec.yaml中添加依赖flutter_native_splash: ^2.4.0
    • 方式二:在命令行执行flutter pub add flutter_native_splash
  • 在项目根目录下新建目录:<project_dir>\assets\images

  • 放入两张启动页面图片,splash_dark.png 和 splash_light.png

  • 在 pubspec.yaml 中加入以下内容**(注意冒号后面有空格!)**:

    flutter_native_splash:
      color: "#FFFFFF"
      color_dark: "#111B21"
      image: assets/images/splash_light.png
      image_dark: assets/images/splash_dark.png
      android_12:
        color: "#FFFFFF"
        color_dark: "#111B21"
        image: assets/images/splash_light.png
        image_dark: assets/images/splash_dark.png
        icon_background_color: "#FFFFFF"
        icon_background_color_dark: "#111B21"
    
  • 项目根目录 Terminal 运行:dart run flutter_native_splash:create

    PS E:\003.CodeBase\git.kuaiyuai.top\KuaiYu-UED\kuaiyu_antibulling> dart run flutter_native_splash:create
    Building package executable... (1.5s)
    Built flutter_native_splash:create.
    [Android] Creating default splash images
    [Android] Creating dark mode splash images
    [Android] Creating default android12splash images
    [Android] Creating dark mode android12splash images
    [Android] Updating launch background(s) with splash image path...
    [Android]  - android/app/src/main/res/drawable/launch_background.xml
    [Android]  - android/app/src/main/res/drawable-night/launch_background.xml
    [Android]  - android/app/src/main/res/drawable-v21/launch_background.xml
    [Android]  - android/app/src/main/res/drawable-night-v21/launch_background.xml
    [Android] Updating styles...
    [Android]  - android/app/src/main/res/values-v31/styles.xml
    [Android] No android/app/src/main/res/values-v31/styles.xml found in your Android project
    [Android] Creating android/app/src/main/res/values-v31/styles.xml and adding it to your Android project
    [Android]  - android/app/src/main/res/values-night-v31/styles.xml
    [Android] No android/app/src/main/res/values-night-v31/styles.xml found in your Android project
    [Android] Creating android/app/src/main/res/values-night-v31/styles.xml and adding it to your Android project
    [Android]  - android/app/src/main/res/values/styles.xml
    [Android]  - android/app/src/main/res/values-night/styles.xml
    [iOS] Creating  images
    [iOS] Creating dark mode  images
    [iOS] Updating ios/Runner/Info.plist for status bar hidden/visible
    Web folder not found, skipping web splash update...
    
    ✅ Native splash complete.
    Now go finish building something awesome! 💪 You rock! 🤘🤩
    Like the package? Please give it a 👍 here: https://pub.dev/packages/flutter_native_splash
    
    PS E:\003.CodeBase\git.kuaiyuai.top\KuaiYu-UED\kuaiyu_antibulling>
    
  • 重新生成项目并运行,查看效果!

参考资源