I've deloped an Android game which supports almost resolutions in the market (240x320, 320x480, 480x800, 480x854, 600x1024).
My problem is when I'm trying to support tablets, I don't understand why Android divide the resources in different folders (hdpi, ldpi, mpdi, large-mdpi, ...) when that qualifiers isn't useful!
I have several graphics sets (according width) but I'm going crazy, for example, with the tablets 480x800 with density mdpi or ldpi! It's is impossible reach every device.
So, do you know any way to divide drawables/bitmaps in folders but only accesible through resolution?? Yes, I know Bitmap Alias but it's not the solution.
Thanks
I believe you're mixing screen size with pixel density:
From the dev guide:
- The platform supports a set of resource qualifiers that let you provide size- and density-specific resources, if needed. The qualifiers for size-specific resources are
small
, normal
, large
, and xlarge
. Those for density-specific resources are ldpi
(low), mdpi
(medium), hdpi
(high), and xhdpi
(extra high). The qualifiers correspond to the generalized densities described in Range of screens supported, above.
- The platform also provides a
<supports-screens>
manifest element, whose attributes android:smallScreens
, android:normalScreens
, android:largeScreens
, and android:xlargeScreens
let you specify what generalized screen sizes your application supports. Another attribute, android:anyDensity, lets you indicate whether or not your application includes built-in support for multiple densities.
Edit: added my comments to the response.
Using the example in the comment, the Archos is a 7 inches screen, while the Nexus One has a 3.7 inches screen. At the same number of pixels, the density of pixels is double on the Nexus One. Remember, dpi means dots per inch. That means that the same image would be rendered twice as big in the Archos than in the Nexus One.
The screen size differences should be handled in the layout. Use res/layout-normal
for the Nexus One and res/layout-large
for the Archos. This way, you will have control over the full layout for the different screen sizes (perhaps you need to limit some widgets that would be unnecessarily large in the Archos) and decide whether you want to keep a fixed size for your drawables or expand them as necessary.
Alternatively, if you really want to keep size proportional to the screen regardless of screen size and without stretching images, then you can create two sets of images, namely image1-normal.png, image2-normal.png and image1-large.png, image2-large.png, etc, both in the res/drawable-mdpi
and the res/drawable-hdpi
folders, that you would access from the xml files in res/layout-normal
and res/layout-large
.
In summary, the full requirements should be handled by a combination of layouts and drawables:
- Nexus One:
layout-normal
, drawable-hdpi
- Archos 7:
layout-large
, drawable-mdpi
- Xoom:
layout-xlarge
, drawable-mdpi