资源文件夹选择无法按预期工作

时间:2012-10-16 11:59:53

标签: android image layout resources

我有一个大图像徽标我正在缩放(通常是向下)以填充屏幕的50%。起初我把它放在base / res / drawable文件夹中。它适用于大多数设备,但在一些小屏幕的低端手机上,缩放引入了混叠,看起来很糟糕。所以我分发了如下图像:

    /res/drawable   
        -Large image, intended to be used on most devices
    /res/drawable-normal
        -Smaller image, intended to target smaller screens

然而,在三星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文件夹中查找然后回退到基本可绘制文件夹吗?

提前致谢。

1 个答案:

答案 0 :(得分:1)

它以可扩展的方式回落。

如果找不到Xlarge,那么large是一个更接近的匹配,那么normal是一个更接近的匹配然后是默认文件夹

参考:

How Android finds best matching resources

Android.Developer

enter image description here enter image description here