This is a scenario. There are folders:
- drawable
- drawable-ldpi
- drawable-mdpi
- drawable-hdpi
- draawble-xhdpi
An image (usually background, but not bound to such images only) is located in /res/drawable
only.
I test the app on Galaxy S3 and the background is displayed properly. I test on HTC One X and background image is not being displayed.
If I copy the image from /res/drawable
to /res/drawable-xhdpi
, the One X will display image.
Thinking logically, this should not be happening, right?! If there is no image in drawable-xhdpi
, then Android should look it into other folders until it reaches the default one /res/drawable
and it should pull it from there.
Why is this not happening on some mobiles?
PS. I noticed the same issue with some tablets, but I cannot remember now which ones.
PPS. I mentioned background image here, but the issue is not bound to it. It also happens with other images. I am aware that xhdpi mobiles have issues with large images and I would not like you to think that the issue was with too large background image. It also happens with other images of "normal" size.
drawable/
folder. It can look in one of the other dpi folders first. So if you have an (empty?) image there then it might get rendered. – Eppsres/drawable/
. That directory is for XML drawables, ones that have no intrinsic "density". – Designeddrawable-nodpi
would be useless in my case – Coltsonres/drawable
, but others were inhdpi
as well. Concerning other image, all of them except one were displayed. I am still trying to find out why this one was not as there is not logical explanation. – Coltsonres/drawable
and then smaller ones in correspondingmdpi, hdpi, xhdpi
folders. What do you mean under "raster images"? I keep a normal PNGs there (no 9.png or similar). – Coltsonres/drawable
, which resolutions should be kept there? mdpi-sized images? – Coltson-mdpi
, probably for backwards compatibility. However, for long-term maintainability, you should put-mdpi
bitmaps inres/drawable-mdpi/
, so that there is no confusion. – Designedhave no intrinsic "density"
. Do you maybe refer do dynamically createdDrawables
? I am as well familiar with the link you provided, but thanks anyway. – ColtsonShapeDrawable
) or are effectivelyif
/switch
statements (e.g.,LevelListDrawable
). None of them behave differently based upon density. XML drawables can safely go inres/drawable/
. Bitmap images should only go in directories that specify what density Android should consider those images to be, such asres/drawable-mdpi/
. – Designed