Drawable folder different screen resolution issues

2019-08-07 13:02发布

I am having the following specification images,

xlarge screens are at least 960dp x 720dp
large screens are at least 640dp x 480dp
normal screens are at least 470dp x 320dp
small screens are at least 426dp x 320dp

Both in portrait and landscape. These are stretched in Tablet. But working fine in mobile. I am handling the configuration changes using the onConfigurationChanged() override method. Is any other way for giving the images for Android application. I reffered the following link for screen sizes. http://developer.android.com/guide/practices/screens_support.html

3条回答
孤傲高冷的网名
2楼-- · 2019-08-07 13:14

Following crocboy link is correct, and i suggest you to try including more buckets on your app. For example, in my applications i use also this:

drawable-sw600dp-mdpi
drawable-sw720dp-mdpi

In this buckets, put images that match tablets screen, for example in drawable-sw600dp-mdpi insert a background with this size 1280x800 and for drawable-sw720dp-mdpi a background with this size 1920x1200.

It's quite difficult to decide wich tablet to target, because we have different screen size.

EDIT

"application have to support all devices. So, the drawable folder images also have to support for all the devices. How to achieve this?". Basically Android create this 4 folder for drawable:

drawable-hdpi
drawable-ldpi
drawable-mdpi
drawable-xhdpi

(To be picky, low drawable-ldpi is not quite used, because small device are loosing appeal)But due to density and screen size you can have:

drawable-large-mdpi
drawable-large-hdpi
drawable-large-xhpdi
drawable-xlarge-hdpi
drawable-xlarge-mdpi

And so on with various combination! If you are looking for image perfection (like my graphics collegue, wich is an iOS psychopath) you have to create images for every type of screen, and put it on relative drawable bucket.

查看更多
放我归山
3楼-- · 2019-08-07 13:19

In the same link ("How to Support Multiple Screens"), they tell you how to create seperate drawable folders for each resolution - such as drawable-hdpi. When the system detects a high-resolution screen, it takes drawables from the high-density folders. You can also do the same with layout folders. If it's a low-resolution screen, it uses only images from the low-resolution images folder, drawable-ldpi. Here is also a good article article about how Android picks images from these folders.

查看更多
神经病院院长
4楼-- · 2019-08-07 13:27

you can use drawable-large for tab

查看更多
登录 后发表回答