当前位置: 动力学知识库 > 问答 > 编程问答 >

android - To have multiple nine-patch images or just one? If one, where to put it?

问题描述:

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?

网友答案:

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.

分享给朋友:
您可能感兴趣的文章:
随机阅读: