Skip to content

configureLaunchScreen ​

从一张源图生成 Android 各密度启动屏 drawable 资源。

前置依赖 ​

参数名类型说明
deps.existsSync / readFileSync / writeFileSync文件读写源图与输出
deps.mkdirSync / join / dirname目录与路径创建 drawable 目录
deps.sharpSharp按密度缩放

环境要求 ​

  • Node.js + sharp

函数签名 ​

typescript
function configureLaunchScreenAndroid(
  imagePath: string,
  projectPath: string,
  moduleDir: string,
  deps: ConfigureLaunchScreenAndroidDeps,
): Promise<ConfigureLaunchScreenAndroidResult>

参数 ​

参数名类型必填说明
imagePathstring是启动图源文件
projectPathstring是Android 工程根
moduleDirstring是如 app
depsConfigureLaunchScreenAndroidDeps是环境依赖

返回值 ​

类型说明
ConfigureLaunchScreenAndroidResult{ success, error?, logs[] }

工作原理 ​

  1. 按 ANDROID_LAUNCH_SCREEN_SIZES 为 ldpi~xxxhdpi 生成对应宽高图片。
  2. 写入 res/drawable-{density}/ 并配置启动屏相关资源(见源码 manifest/styles 步骤)。
  3. 全程收集 logs,失败返回 error 文案。