You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

flutter_native_splash安卓启动图横向拉伸,如何维持原比例显示?

解决flutter_native_splash Android端图标横向拉伸问题

核心解决方案

在你的pubspec.yaml配置中添加Android端的图片对齐参数,让图标保持原始比例居中显示,而非拉伸填充容器:

flutter_native_splash:
  color: "#ffffff"
  image: assets/images/icons/icon.png 
  branding: assets/images/icons/branding.png
  android: true
  ios: true
  # 为传统Android版本设置图标居中对齐,避免拉伸
  android_gravity: center
  android_12:
    color: "#ffffff"
    image: assets/images/icons/icon_android.png
    branding: assets/images/icons/branding.png
    # Android 12+同样设置居中对齐
    android_12_gravity: center

额外优化建议

  • 确保你的图标图片为方形(推荐1080x1080像素),宽高比差异过大会加剧适配问题
  • 减少图标周围的空白区域,保证在不同分辨率设备上的显示清晰度

生效步骤

修改配置后,重新执行生成命令:

flutter pub run flutter_native_splash:create

内容的提问来源于stack exchange,提问作者sub

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.03 03:41:01