61

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
LOG_TAG
  • 19,894
  • 12
  • 72
  • 105
wufoo
  • 13,571
  • 12
  • 53
  • 78
  • No you don't need to, i have implemented my own way of handling multiple screen resolutions, refer to this http://stackoverflow.com/a/16518557/1939564 – Muhammad Babar Sep 09 '13 at 06:13
  • That's certainly an innovative approach! Part of the reason for the multiple layout capability however is to also enable the developer to use screen resources differently depending on what device or orientation the application is running on. I think it's only fair to point out that iOS uses the exact same method. There is Storyboard (layout) for iPad as well as iPhone devices. You must maintain both if you want a cross-device application. . – wufoo Mar 13 '14 at 14:45
  • @wufoo I really appreaciate your table. Is there a possibility to get also numbers for newer screens (they got bigger, like xxlarge,..) ? Or if you can reffer me a link to it, I'd apprecaite it! – David Kasabji Mar 16 '16 at 23:10

4 Answers4

23

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.

Marcos Vasconcelos
  • 18,136
  • 30
  • 106
  • 167
Waza_Be
  • 39,407
  • 49
  • 186
  • 260
  • 2
    Thanks. But what I'm having trouble with specifically are image backgrounds. My company wants to put up a splash-screen when the application starts and it really scales weird depending on the orientation of the device. I fixed that by making two splash-sceen images; one portrait, one landscape however the problem now is when I run the app on the Xoom, the splash-screen is all blurry and jaggy. If I scale a Xoom resolution splash-screen down to a QVGA emulator, the text becomes unreadable. So, do I make a different res splash-screen for every device, or is there a happy medium somewhere? – wufoo Apr 06 '11 at 18:29
  • 2
    You just need to add a different image/layout in xlarge and/or xlarge-land then the xoom (and other xlarge screen devices) will use those, and all others will look at the normal ones. – stealthcopter May 14 '11 at 11:53
  • 4
    mixing the meaning of ldpi and small terms leads to this confusion.. Check http://developer.android.com/guide/practices/screens_support.html under section Using configuration qualifiers small, normal, large, xlarge should be used for providing different layouts.. ldpi, mdpi, hdpi, xhdpi should be used to provide different image sizes.. Just my opinion... – Ewoks Apr 23 '12 at 09:57
  • I have different layouts for each, but still not working. http://stackoverflow.com/questions/34378238/landscape-mode-for-app – Ruchir Baronia Dec 20 '15 at 09:07
8

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::).

LOG_TAG
  • 19,894
  • 12
  • 72
  • 105
  • what about kindle HD 7 ? it's under sw530dp and Samsung Tab 7 can't identify "sw" qualifier as it has 2.3 and in my app minimum SDK is 8. – Vishal Khakhkhar Mar 13 '14 at 11:42
  • @VishalKhakhkhar almost my hair started becoming gray!! read this solution: http://stackoverflow.com/questions/13156157/nexus-7-and-kindle-fire-hd-think-different – LOG_TAG Mar 13 '14 at 11:46
  • Yes that's true.. that means it is must to implement large for Old Samsung Tab 7 and sw530 common for Kindle 7 and Nexus 7 right ? – Vishal Khakhkhar Mar 13 '14 at 11:47
  • and about XLarge.. Xoom devices with OS 3.0 can't get layout from sw720. So must have to add Xlarge too.. any other solution ? – Vishal Khakhkhar Mar 13 '14 at 11:49
  • This seems to read that supporting devices from 2.3.7 on up, it will require using even more layouts. yikes! – wufoo Mar 13 '14 at 14:47
  • How do we change the orientation of the layout file using sw qualifiers. – Ruchir Baronia Sep 04 '16 at 00:39
2

In the layout if you do not use AbsoluteLayout, you application is going to be resized to fit the screen.

But in some cases, for smaller screens you need declare a new layout with less components for example.

For images:

You has some options.

Simple ignore some resolutions and let the device choose the best image to it. Declare on AndroidManifest for wich sizes you want to support. Or has just one and let the resize screw your application.

Marcos Vasconcelos
  • 18,136
  • 30
  • 106
  • 167
  • I have different layouts for each, but still not working. http://stackoverflow.com/questions/34378238/landscape-mode-for-app – Ruchir Baronia Dec 20 '15 at 09:08
0

Yes. You should define different layout for different screen resolution.

When you are supposed to work with tablet kind of application. That time really you feel that. There is a need of different layout. Because Tablets always comes in different size.

One more thing, When you are working on android, means you should always taste your app with real device. And also test with different size emulators.

shivaprakash
  • 33
  • 1
  • 12