中性可绘制文件夹中应放置多大尺寸的图像?
我有一个5 个不同 版本的图标文件:
- 24x24 = ldpi
- 32x32 = mdpi
- 48x48 = 高清像素
- 64x64 = xhdpi
- 96x96 = xxhdpi
另一方面,我有6 个不同的 文件夹:
- /可绘制
- /drawable-ldpi
- /drawable-mdpi
- /drawable-hdpi
- /drawable-xhdpi
- /drawable-xxhdpi
5 个文件和 6 个文件夹意味着要么一个文件夹必须保持为空(哪个?),要么一个文件必须使用两次?
这就是docs说:
If no matching resource is available, the system uses the default resource and scales it up or down as needed to match the current screen size and density
The "default" resources are those that are not tagged with a configuration qualifier. For example, the resources in drawable/ are the default drawable resources. The system assumes that default resources are designed for the baseline screen size and density, which is a normal screen size and a medium density. As such, the system scales default density resources up for high-density screens and down for low-density screens, as appropriate.
However, when the system is looking for a density-specific resource and does not find it in the density-specific directory, it won't always use the default resources. The system may instead use one of the other density-specific resources in order to provide better results when scaling. For example, when looking for a low-density resource and it is not available, the system prefers to scale-down the high-density version of the resource, because the system can easily scale a high-density resource down to low-density by a factor of 0.5, with fewer artifacts, compared to scaling a medium-density resource by a factor of 0.75.
好的,mdpi版本应该放在drawable-mdpi,ldpi放在drawable-ldpi等等,这是没有问题的。但是哪个版本进入中性文件夹?
我应该将 xxhdpi 文件放在那里(如果找不到匹配项则缩小)?那 -xxhdpi 文件夹呢?将其留空还是将文件也放在那里?
最佳答案
默认的 /drawable
文件夹需要 mdpi 图像
。主要用于 2 种情况:
To have non-density dependent images. eg: selectors, which indirectly link to images from density named folders again.
To have all the images in only this folder and ignore all the other drawable folders. In which case the images will be scaled depending on the screen density.
针对您的情况:
You can keep only xml files like selectors in the default
/drawable
folder and other images in their respective folders
关于android - 中性可绘制文件夹中应放置哪种图像尺寸?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24199128/