首页 > 解决方案 > 在 react-native-bootsplash 中调整初始屏幕图像的大小

问题描述

我正在开发一个 react native 项目,我使用 react-native-bootsplash 作为我的启动画面。问题是启动画面上的标志图像太小,因为启动画面标志的推荐尺寸为100。有没有办法调整图像大小或使用bootsplash生成的@5x图像?

标签: react-nativereact-native-android

解决方案


我在 react-native-bootsplash 的文档(https://www.npmjs.com/package/react-native-bootsplash)上找到了这个:

react-native generate-bootsplash <logoPath>命令有几个参数:

Options:
  --background-color <color>  color used as launch screen background (in hexadecimal format) (default: "#fff")
  --logo-width <width>        logo width at @1x (in dp - we recommand approximately ~100) (default: 100)
  --assets-path [path]        path to your static assets directory (useful to require the logo file in JS)
  --flavor <flavor>           [android only] flavor build variant (outputs in an android resource directory other than "main")
  -h, --help                  output usage information

所以如果你想创建一个大于默认大小 100 的 bootsplash,你可以这样做:

yarn react-native generate-bootsplash assets/bootsplash_logo_original.png \
  --background-color=F5FCFF \
  --logo-width=300 \
  --assets-path=assets \
  --flavor=main

我只想确保您的徽标具有足够高的质量,以便您的 bootsplash 仍然看起来不错。


推荐阅读