tags:

views:

84

answers:

1

Hello, I have a written a game that works fine on the 'normal' 320x480 screen of my G1. I tried it on a friends Xperia x10 and it leaves a large blank section on the right hand side of the screen. How do I fix this? I've read that I need to include an extra directory in res/drawable for different densities. How do I do this?

Thanks for any help

Caroline

A: 

The table on the page that Yoni references describes the various screen sizes and resolutions that are currently available.

Check the best practices on the same page: http://developer.android.com/guide/practices/screens_support.html#screen-independence

If you follow the steps mentioned there, you shouldn't have any trouble. If you have set the resources up correctly (i.e., using dip rather than px), resources will scale, so you do not necessarily require different size resources (though you may want them in order to keep things looking nice).

I'd suggest using either mdpi/hdpi or normal/large for your resources - having both is overkill.

Michael A.
Hello Michael - Many thanks for your information. What I am failing to understand at this point is how to set up resources correctly (i.e. using dip etc). I just assumed that you could just scale up an image in Photoshop or whatever for hdpi. I don't understand how you can change the dip in Photoshop.Basically all I need is an explanation of what goes in which directory and what size. E.g. a 320x480 image on a G1 in 'drawable' works fine. To get get it to work on say a Droid, what size and where do I put it? The documentation does seem to contradict itself.
Dave B
Using dip is an internal android thing. Essentially what you are doing internally in Android when specifying 10 dip, is to tell Android to make the object 10 pixels on a standard screen, but 15 pixels on a high resolution screen (I forget the exact numbers, but I think it is x1.5). In general, you should go through all your layouts and make sure that you always use dip/dp and not px for your sizes.
Michael A.
In general, you should not use a "drawable" directory. There is a bug in one of the Android versions (I forget which, but it is either 1.6 or 2.0) that makes it pick the wrong resources if the "drawable" directory exists. The best setup, I've found, is to use explicit "drawable-mdpi" and "drawable-hdpi" directories. Resources that you place in the drawable-hdpi directory will be used as is - not scaled. So your 320x480 graphic in mdpi should be upscaled to 480x800/850 in the hdpi resources. If a graphic is not available for hdpi, android will try to get the resource from mdpi and upscale it.
Michael A.
Note: Since mdpi resources will be scaled automatically, you can save on app space by only manually scaling where it is vital for the resources to have the correct proportions/looks on the hdpi screen.Hope that helped clarify a bit.
Michael A.
Michael, thankyou very much for the info. I tried it and it works! I found the 'drawable' directory bug and nearly tore all my hair out, until I tried the separate dirs for -mdpi and -hdpi!!! So, once again thanks for all your help!
Dave B