2
votes

I have a quick question regarding Android resolutions and how it is represented on the emulator. I have set up a test project to test many different resolutions and how they look on each orientation. So I have created drawable-land-ldpi,mdpi,hdpi-xhpdi and done the same thing for drawable-port. I also have all the layout folders, i.e. small med large x large, small-land,med-land,large-land, x-land

I have created 8 test images, that just say small port, land, medium port, land etc and so on just to check Android is choosing the correct image. I have also created a layout file for each layout folder, in the layout files I have a text field which just specifies the folder name so I know which layout folder is being used.

I have two questions, first is am I creating the correct image size for each folder. The image sizes I have created as are follows

drawable-land-ldpi - 320 * 240 drawable-port-ldpi - 240 * 320

drawable-land-mdpi - 480 * 320 drawable-port-mdpi - 320 * 480

drawable-land-hdpi - 800 * 480 drawable-port-hdpi - 480 * 800

drawable-land-xhdpi - 1080 * 720 drawable-port-xhdpi - 720 * 1080

And my second question is why do these not seem to represent properly on the emulator? Example, I have created an Android app with one screen and the images in the appropriate folders. I have created two emulators, one is 2.3.3, and one is a 3.0 tablet.

If I run the device on my device which, it uses the image from the medium resolution folder and uses the medium layout folder. So if it is port it will use the layout from the default layout folder and the image from the drawable-port-mdpi and if its landscape it will use the layout from the default land folder and the image from the drawable-land-mdpi.

However if I run this on the emulator, on the 2.3.3 device, it uses the layout folder from the medium layout folder, but the image from the drawable-hdpi-port and if its landscape uses the medium landscape layout folder, but the image from the drawable-hdpi-land. If I run it on the 3.0 tablet emulator, it uses the correct layout from the xLarge port and xLarge land, but it uses the image from the drawable-mdpi folders.

I have set up in the manifest to support all resolutions and layouts. Is there any reason why the emulator is doing this? I don't have an Android tablet on me at present to test this as friend forgot to bring it, so I can't test if this works fine on the tablet yet.

I would like to be able to use the emulator to try out a range of devices to test, but if it is not choosing the correct image then I cannot rely on it. Anyone else have issues like this? Or am I doing something wrong?

Any information would be much appreciated!!

1

1 Answers

1
votes

Pixel density matters. For instance, your hdpi images may be the right size, but with an incorrect pixel density, they will still get scaled in those folders. For instance, your hdpi images should have a pixel density of ~240dpi. Check the developer guide for supporting multiple screen sizes:

http://developer.android.com/guide/practices/screens_support.html

Another issue is that the screens may be a variety of sizes, along with different pixel densities, e.g., a tablet could be 10 inches (X-Large), but still have a medium pixel density (1280x800). At the same time, you could have another tablet that's also 10" with xhdpi, if the resolution was something like 2560x1600.

It might be better for you to specify your actual layout folders based on pixel density. i.e., you can make folders:

res/layout-sw600dp/main_activity.xml   # For 7” tablets (600dp wide and bigger)
res/layout-sw720dp/main_activity.xml   # For 10” tablets (720dp wide and bigger)

And you can still apply port and land to them. Read up on the page about supporting multiple screen sizes, it will probably really help to answer a lot of your questions.