Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do I need 14 different layouts to support all Android devices?

I'm really feeling confused. From the docs at developer.android.com, it seems in order to keep my images scaled correctly (aspect ratio too) across all current Android devices I need all these layouts below. Is that really what everyone is doing? Am I missing something, or should I be going about this a different way?

Low density Small screens QVGA 240x320 ------------------------------------------------ layout-small-ldpi layout-small-land-ldpi  Low density Normal screens WVGA400 240x400 (x432) ------------------------------------------------ layout-ldpi layout-land-ldpi  Medium density Normal screens HVGA 320x480 ------------------------------------------------ layout-mdpi layout-land-mdpi  Medium density Large screens HVGA 320x480 ------------------------------------------------ layout-large-mdpi layout-large-land-mdpi  High density Normal screens WVGA800 480x800 (x854) ------------------------------------------------ layout-hdpi layout-land-hdpi  Xoom (medium density large but 1280x800 res) ------------------------------------------------ layout-xlarge layout-xlarge-land 
like image 806
wufoo Avatar asked Apr 05 '11 21:04

wufoo


People also ask

How can I make Android apps compatible with all screen sizes?

The best way to create a responsive layout is to use ConstraintLayout as the base layout in your UI. ConstraintLayout enables you to specify the position and size of each view according to spatial relationships with other views in the layout. All the views can then move and resize together as the screen size changes.


2 Answers

Your app will work on 100% of the devices with the classic layout.

You can just add some buttons or change the layout in landscape mode by adding some qualifiers but that's up to you!

For instance, on LDPI (small resolution) device, you may want to adjust some buttons or change a little bit to fit the small screen.

You may also want to put some buttons on the right in landscape mode and in the bottom of your layout in portrait!

You do not "have to" use them.

like image 134
Waza_Be Avatar answered Sep 24 '22 08:09

Waza_Be


According to Android Dev Protip from Roman Nurik about screen size qualifiers:

If you have custom layouts for larger screen devices such as tablets, now's the time to stop using the -large or -xlarge resource qualifier and switch to using -swXXdp or -wXXdp qualifiers. The latter were introduced in API level 13, which basically all tablets now have support for according to the latest platform version charts1.

means that for basically all cases where -large would have any effect, -swXXdp can be used instead to provide more granularity.

So which actual sw or w qualifiers should you use? Here's a quick just-give-me-something starting point:

7" tablets: Instead of layout-large, use layout-sw600dp.

Example: Nexus 7 = 960×600 dp; the smaller of the two dimensions is 600.

10" tablets: Instead of layout-xlarge, use layout-sw720dp.

Example: Nexus 10 = 1280×800 dp; the smaller of the two dimensions is 800. Some 10" tablets are a bit more narrow so 720 is a commonly used switching point.

There's more to it than just that (you really want to choose switching points based on your content's minimum requirements, not on device form factor), but that's a #Protip for another day (::cough:: +Nick Butcher ::cough::).

like image 31
LOG_TAG Avatar answered Sep 22 '22 08:09

LOG_TAG