Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android multiple-screen qualifiers definitions

I wanna create a layout compatible with a very large number of devices and screens. As I have been researching I found out that the most common screen resolutions are 249x320, 480x800, 600x1024, 720x1280 (and some other screens proportional to these).

Well, after reading the documentation I found out that there are two ways of doing it. Up to the 3.2 Android version I could use qualifiers for the layouts like "small, normal, large, xlarge" and combine them with "port" (portrait orientation) or "land" (landscape orientation".

Now, the second way (that seems to be the most recommended) is working only for Android 3.2 and later versions. You must specify the smallest width for which a layout must be used, no matter the screen orientation (???).

For the fact that you cannot specify the port or land qualifiers when using the second method, I prefer the first one. My question is: is the first method compatible with Android 3.2 and later versions? Must I use the first method for Android < 3.2 and the second for Android > 3.2? If so, I should create two projects, or maybe combine these two methods (create about 10 layout sizes, for the general-size qualifiers and for the specific minimum-width qualifiers). That would need more resources, I suppose.

Thanks and sorry for my bad language.

like image 762
ali Avatar asked Nov 14 '22 07:11

ali


1 Answers

In Android you don't design your layouts based on pixels... you design them based on density independent pixels (dip or dp). These are device pixels scaled by the dots per inch screen density of your device. Android has 4 general screen density buckets, and you must provide drawables for each one under an appropriate folder (res/drawable-ldpi, res/drawable-mdpi, res/drawable-hdpi, res/drawable-xhdpi).

Other ways to make your layout compatible with a multitude of devices is to use 9png stretchable graphics, and use XML drawables that rely on dp for their dimensions.

Recommended reading for Android screen support:
http://developer.android.com/guide/practices/screens_support.html

As far as the smallest-width qualifier, you are missing the fact that the smallest width is specified in dp, not pixels. Check Table 2 in this section:
http://developer.android.com/guide/topics/resources/providing-resources.html#AlternativeResources

The first method works on all devices, including Android 3.2+.

like image 88
Theo Avatar answered Nov 16 '22 04:11

Theo