React Native 上多屏幕密度的图像

Images for Multiple Screen Densities on React Native

React Native Docs 告知:

You can also use the @2x and @3x suffixes to provide images for different screen densities. If you have the following file structure:

.
├── button.js
└── img
    ├── check.png
    ├── check@2x.png
    └── check@3x.png

the bundler will bundle and serve the image corresponding to device's screen density.

并且Android App Bundle Docs告诉,

Google Play then uses the app bundle to generate the various APKs that are served to users, such as the base APK, dynamic feature APKs, configuration APKs, and (for devices that do not support split APKs) multi-APKs.

我有多个图像支持不同的屏幕密度(img.pngimg@2x.png 等)。如果我以 .aab 格式构建应用程序,我的不同屏幕密度图像是否会根据屏幕密度分开并放置在不同的资产包中?

did my different-screen-densities-images will be separated and placed on different asset/resource pack based on screen densities?

答案是否定的,它没有。

这是我完成的步骤: 1.创建新项目作为实验 2. 将一些图片放在 JS Codebase {image.png: 1kb, image@2x.png: 2kb, image@3x.png: 2.5mb} 3. 建成 .aab 4. 创建了许多 phone spec json 文件 5. 提取 .aab.apks 多达 phone spec json 文件 6. 比较所有 .apks created

的总大小

结果总大小相同。我预计 xxxhdpi .apks 上的总文件大小会有显着差异。但它没有。

然后,我好奇地尝试了另一个实验。

我将所有图像从 JS 代码库移至 Android 本机代码库(drawable-xxx 目录)。我执行步骤 2-6。

导致总大小不同。 xxxhdpi .apks 的文件大小明显大于另一个