176 字
1 分钟
android资源配置
2021-11-07
2026-10-12
无标签

一、 App名称#

android - app - src - main - AndroidManifest.xml - android

1

二、 图片资源#

与 iOS 不同,安卓应用的图片资源不是按 1x 2x 3x 来区分的。

android - app - src - main - res

哦们可以看到以下目录:

2

  • mipmap-mdpi
    • 相当于 1x
  • mipmap-hdpi
    • 相当于 1.5x
  • mipmap-xhdpi
    • 相当于 2x
  • mipmap-xxhdpi
    • 相当于 3x
  • mipmap-xxxhdpi
    • 相当于 4x

3

4

注意: 命名不能驼峰,用下划线

三、 启动页#

5

四、 其他图片#

修改 pubspec.yaml 文件

# To add assets to your application, add an assets section, like this:
# assets:
# - images/a_dot_burr.jpeg
# - images/a_dot_ham.jpeg

注意:这里格式需要严格对齐

错误:

6

正确:

7

这里写入文件夹路径或者文件路径都可以

五、 使用图片#

Image(image: AssetImage('路径/xxxxxx.png'))