android - 资源文件夹选择未按预期工作

标签 android image layout resources

我有一个大图像 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.Developer

enter image description here enter image description here

关于android - 资源文件夹选择未按预期工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12914219/

相关文章:

javascript - 使用输入类型文本以表单形式上传图像

html - 闯入 : avoid-column;//not working

html - 标题+内容在不滚动的情况下达到 100% 高度的最佳解决方案是什么

android - 如何修复单击时错误的 alertDialog?

java - Android - 如何在 View 组内设置 subview

c# - 对于 jpg 图像文件,获得 3-4 种平均主色

使用图像的 CSS 可伸缩文本输入

html - 在均匀间隔的列中布局 HTML 列表

android - 在 Ubuntu 11.04 Natty 上进行 Android 调试

Android - 将生成的 C 文件与 JNI 一起使用