Question

So far, I always created one nine-patch image and place it inside /res/drawable-hdpi.

But I saw some large projects which have multiple nine-page images, scaled and placed inside multiple res/drawable-xxx directories. Is this the wrong approach? Nine-patch was supposed to stretch across all screens, regardless of its DPI.

Also, if I am right and only one nine-patch is to be used, what is its default location - drawable-hdpi, mdpi, or some other directory inside /res?

Was it helpful?

Solution

Well, it really depends on quality.

If your image is just a square border, it can be a 72 dpi low res image put into the drawable folder and it would be enough.

If your image has rounded corners or other fancy elements that have to be scaled properly, you could make a 480 dpi version and put it in the drawable-xxhdpi folder. This will scale down (don't even think of scaling up, because of stretching/pixellating) good enough in most cases.

If you want the best quality in scaling, then make a version for each dpi drawable folder.

If you go to http://developer.android.com/guide/topics/resources/drawable-resource.html, you can see it there (citation):

file location:
res/drawable/filename.9.png
The filename is used as the resource ID.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top