Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Force load desired dpi drawables according to screen size

I have 4 sets of images

Resolutions        DPI      Directory
240 x 320          120dpi - drawable-ldpi
320 x 480          160dpi - drawable-mdpi
480 x 800          240dpi - drawable-hdpi
1280x 800          320dpi - drawable-xhdpi

But when I tested it at ASUS transformer with resolution 1280x800 and DPI 224. It loaded graphics from drawable-hdpi.

If I will add another folder with name drawable-xlarge, It will load desired images but it will increase the size of application as well.

My questions are as follows

1 - What is the best practice to support all screen sizes and DPI?

2 - Is there any way to force load drawable of particular DPI w.r.t screen size?

3 - What is the solution recommended for my problem without replicating the graphics?

like image 666
Syed Muhammad Umair Avatar asked Oct 22 '22 02:10

Syed Muhammad Umair


1 Answers

But when I tested it at ASUS transformer with resolution 1280x800 and dpi 224. It loaded graphics from drawable-hdpi.

That is because the ASUS Transformer is an -hdpi device. Hence, it is working properly.

What is the best practice to support all screen sizes and dpi?

Usually, images only vary based on density, and so your current structure is fine.

If you elect to have images that vary both on screen size and density, you will need to make more directories (e.g., res/drawable-xlarge-hdpi/) and images for the

Is there any way to force load drawable of perticular dpi w.r.t screen size?

Density and screen size have nothing to do with one another.

What is the solution recommended for my problem without replicating the graphics?

According to your "question", you do not have a problem. Hence, there is no recommendation for your non-problem.

like image 161
CommonsWare Avatar answered Oct 31 '22 12:10

CommonsWare