However there are the specific foldersdrawable-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

更多相关文章

  1. Android 7.1使用以太网口共享本机4G网络给其他设备
  2. android图片压缩 —— 2
  3. Android SD卡,文件,文件夹工具
  4. Android RadioButton 图片位置和大小
  5. Android 获取设备的物理尺寸
  6. Android 实现图片闪烁效果
  7. Android 调用相册或相机选择图片
  8. android各种图片获取路径的方式
  9. Android 获取drawable中图片的高度宽度

随机推荐

  1. Andoid - 开发实例(2): ViewPager卡片式界
  2. "Failed to fetch URL https://dl-ssl.go
  3. Android中调用startActivity结果导致:java
  4. 简单的android折线图绘制
  5. 【Android】Android自定义属性,attr forma
  6. Android 8.1 (O) Launcher3 方面修改
  7. Android临时数据缓存方法
  8. android中的内部类
  9. 基于Android Q 修改默认音量等级
  10. android真实项目教程(四)——MY APP MY STY