1

This is my first venture in sw qualifiers and I appear to be missing the mark. Looking into this I see soo many directions on figuring out how to correctly calculate what is needed and through trial and error, I have landed back on error.

What I would like to do is define a layout (port and land) for all devices up to a certain size. Above that size use a seperate layout (port and land).

The 2 devices in my possession which identify the line in the sand so to speak:

4.7” 720x1280 (quantized density 300)
4.3" WVGA 480 x 800 (quantized density 240)

What I want to do is use a certain layout < 720x1280

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
DevinM
  • 1,112
  • 1
  • 12
  • 29
  • I accomplished this by adding a method to my activity that will log the dp height and width https://stackoverflow.com/questions/30869168/confusion-in-smallest-width-dp-in-android After running on both devices I have the metrics needed to correctly setup sw qualifiers however there must be an easier way about this. What happens when i dont have the device in my possession? – DevinM Feb 21 '19 at 02:22
  • res/layout/ and res/layout-land contains the layouts for smaller density devices and res/layout-sw384dp/ and layout-384dp-land/ contains layouts for the larger density devices. This seems to work as expected. – DevinM Feb 21 '19 at 02:24

1 Answers1

3

In my experience, there are some consistent "buckets" used for smallest-width values. These are

  • default: used for everything
  • sw360dp: excludes the smallest phones (sometimes 320 or even 240 dp wide)
  • sw411dp: differentiates wider-screen flagship phones from narrower-screen ones
  • sw533dp: slightly undersized tablets (think the original Kindle Fire)
  • sw600dp: standard seven-inch tablets
  • sw720dp: standard ten-inch tablets

There's no hard line. It's quite possible for one phone to have a smallest width of 399dp and another to have 401dp; you just have to make a judgement call.

I'd recommend thinking about it not from the perspective of "how can I differentiate these two devices?" but instead from the perspective of "at what point do I have enough room to change my layout?" Maybe once you have at least 400dp to work with, you can change your layout to include more features. Or maybe you need 517dp to get that extra content in. When you think about it this way, then whatever bucket any given device happens to fall inside, it will have a layout that looks like it was designed for that screen size.

There are also some online resources that provide specs for a large number of devices; perhaps you can use these to determine where you want to draw the line. For example: https://material.io/tools/devices/

Ben P.
  • 52,661
  • 6
  • 95
  • 123