0

I am looking to support a devices (TVs, tablets , phones)

I have the following directory setup.

res/layout/
res/layout-small/
res/layout-large/
res/layout-xlarge/

I expected layout-xlarge to target only TVs but it seems to target my 10 inch tablet as well.

Can anyone tell me why this is?

Should I try using the screen width directory structure/

e.g. res/layout-sw600dp etc.

Fabii
  • 3,820
  • 14
  • 51
  • 92

2 Answers2

2

Using '-small', '-large', etc, targets the resolution. So a small device with a high DPI would count as an '-xlarge' (For instance, the Nexus 5).

The correct way to do it, as you said, is to use the dp structure (-sw600dp, as you said).

dp in Android is a unit for density independent pixels: What is the difference between "px", "dp", "dip" and "sp" on Android?

Using 'tvdpi' might be a good idea for targetting TV's as well.

Here is a good resource for this information:

http://developer.android.com/guide/practices/screens_support.html

Community
  • 1
  • 1
elimirks
  • 1,452
  • 2
  • 17
  • 30
  • What ranges would I use to represent sizes from phones to TVs ? 320dp, 480dp, 720dp? – Fabii Jan 03 '14 at 22:14
  • 2
    Here is the section explaining that: http://developer.android.com/guide/practices/screens_support.html#ConfigurationExamples – elimirks Jan 03 '14 at 22:16
  • 1
    There's a platform version issue here. If the minSdkVersion is 13 (Honeycomb 3.2), then the `-sw600dp` qualifier is enough. If the minSdkVersion is lower than that, then the named sizes are also needed. The [Screen Sizes](http://developer.android.com/training/multiscreen/screensizes.html#TaskUseAliasFilters) training contains a useful alias trick to avoid XML duplication. – Barend Jan 03 '14 at 22:18
1

I use the following:

-sw320dp (or default) for smaller phones
-sw360dp for regular phones
-sw480dp for huge phones
-sw600dp for 7" tablets
-sw720dp for 10" tablets

You can also specify pixel densities, such as -ldpi, -mdpi, -hdpi, -xhdpi, and -xxhdpi.

Here's a screenshot from one of my projects. Here, I attempt to provide the perfect images for all screen sizes and densities. This may be overkill for what you are trying to do.

multiple_sizes

For more information, please see http://developer.android.com/guide/practices/screens_support.html

BVB
  • 5,380
  • 8
  • 41
  • 62
  • Wow that is some specificity. My app is already considerably larger than I would like it just with support for mdpi, hdpi, xhdpi – ClintL Jan 03 '14 at 23:42
  • I have around 5 images in each of those directories and my total app size is under 5 MB. I believe the average Android app is 6-8 MB. I only use simple vector images converted to pngs and trimmed via pngquant. I wrote a post about it here: http://aleakymemory.blogspot.com/2013/11/a-different-look-at-managing-android.html This is not a good idea if your images are larger. – BVB Jan 04 '14 at 00:08