我有一个大图像 Logo ,我目前正在缩放(通常缩小)以填充屏幕的 50%。起初我把它放在基础/res/drawable 文件夹中。它适用于大多数设备,但在一些小屏幕的低端手机上,缩放引入了锯齿,看起来很糟糕。所以我按如下方式分发图像:
/res/drawable
-Large image, intended to be used on most devices
/res/drawable-normal
-Smaller image, intended to target smaller screens
但是,在 Samsung Galaxy Tab 2 10' 上进行测试时,它会选择普通文件夹中的图像,而不是基本可绘制文件夹中的图像。我知道这款平板电脑属于 drawable-xlarge 类别,因为它从那里挑选其他资源。所以我必须想出这个目录结构才能工作:
/res/drawable
-Large image, intended to be used on most devices
/res/drawable-normal
-Smaller image, intended to target smaller screens
/res/drawable-xlarge
-Same image as the drawable base folder, only used for the tablet to select the correct image.
现在它如我所愿,但我不明白为什么系统会为超大型设备选择普通文件夹。它不应该先在 xlarge 文件夹中查找,然后回退到基础可绘制文件夹中吗?
提前致谢。
最佳答案
它以可扩展的方式回退。
如果找不到 Xlarge,那么 large 是更接近的匹配然后 normal 是更接近默认文件夹的匹配
引用:
How Android finds best matching resources
关于android - 资源文件夹选择未按预期工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12914219/