However there are the specific folders drawable-ldpi, 'drawable-mdpi', 'drawable-hdpi' and even 'drawable-xhdpi' together with the basic 'drawable' folder.
在Android中有三种特殊的文件夹drawable-ldpi, drawable-mdpi, drawable-hdpi 有时甚至有drawable-xhdpi, 以及基本文件夹drawable
Maybe you are familiar with all those, but I will repeat their usage patterns, because I have a feeling this might be failing you. The ldpi, mdpi, hdpi and xhdpi mean low, medium, high and extra high dpi - different screen resolutions. Android has a special way of determining the hardware characteristics of the device you are running on and thus mapping it to the most relevant: ldpi, mdpi, hdpi or xhdpi.
可能你已经非常熟悉他们了,但是我仍将重复它们的使用模式,因为我感觉你会在这上面犯错误。ldpi, mdpi, hdpi and xhdpi意味着低、中等、高、和非常高像素的不同的屏幕解决方案。Android有一种特殊的方法通过决定你将要运行的硬件设备的属性来将硬件设备映射到最相屏幕解决方案:ldpi, mdpi, hdpi,或是xhdpi
When it comes to a place in which you need an image say image.png it first searches for drawable-mdpi/image.png (if it has determined your device to be mapping to mdpi). If such image is not found it goes and tries drawable/image.png and will rescale it if found. And that's it, if those two searches have failed and you have supplied the image in some of the other resolutions' folder it will not use it. This means that if you install the app on xhdpi device and have supplied only ldpi and mdpi image on such device no relevant image will be found.
当它来到一个地方,在那里需要一个图片,例如image.png时,它首先查找drawable-mdpi/image.png (假设它已经决定你的设备将要映射到mdpi),如果这个文件没有找到,它将尝试查找drawable/image.png 如果找到了就缩放它。也就是说,如果那两个查找都失败了而你已经提供了这张图片且放在了其它图片像素解决方案的文件夹内,系统将不会使用它。这意味着如果你安装你的app到xhdpi,并且只为此设备提供了ldpi和mdpi图片,那么相关的图片将会找不到.
这种问题将会导致的错误:
android.content.res.Resources$NotFoundException: Resource is not a Drawable