使用Flutter Native Splash时自定义启动页图标不显示问题求助
Flutter Native Splash 启动页图标不显示问题
代码及运行结果截图:
使用Flutter Native Splash自定义启动页时,仅背景颜色生效,图标未在启动页中央显示,预期效果为蓝色背景下图标居中显示。
解决方案:
- 检查
pubspec.yaml配置,确保图标路径、参数设置准确:flutter_native_splash: color: "#007AFF" # 蓝色背景 image: assets/images/launch_icon.png # 确认图标路径真实存在 android: true ios: true image_scale: 0.6 # 按需调整图标缩放比例,避免显示异常 - 确认图标文件格式为PNG,且路径下文件无损坏
- 重新生成启动页资源:
flutter pub run flutter_native_splash:create - 清理缓存后重建项目:
flutter clean flutter pub get flutter run - Android平台可手动调整
android/app/src/main/res/drawable/launch_background.xml,确保图标居中:<ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:src="@drawable/launch_icon" /> - iOS平台可检查
ios/Runner/Assets.xcassets/LaunchImage.imageset资源,或在LaunchScreen.storyboard中手动设置图片视图为居中布局
内容的提问来源于stack exchange,提问作者R21
相关产品推荐
相关产品推荐

