dimens.xml in values folder for 7" and 10" tablet, how to?
Asked Answered
H

2

6

I have tried with:

values-mpdi, values-land-mpdi, values-hpdi and values-land-hdpi

which works fine in phone's screens, the problem is that it could happen that a 7" tablet takes the value from values-mdpi and a 10" tablet too, but the result is not the same, I guess because of the screen size (although is the same resolution and similar density) so I tried:

values-sw600dp-hdpi
values-sw600dp-port-hdpi
values-sw600dp-mdpi
values-sw600dp-port-mdpi
values-sw720dp-hdpi
values-sw720dp-port-hdpi
values-sw720dp-mdpi
values-sw720dp-port-mdpi

but the app crashes because it does not find the resource needed....

any help will be much appreciated

thanks in advance

Hame answered 17/5, 2012 at 19:20 Comment(1)
for checking out screen parameters on individual devices, I've found the DisplayInfo app to be really handy: play.google.com/store/apps/details?id=it.gerdavax.displayinfoSosa
A
17

Basically three main device categories exist that Android applications need to support:

  1. handsets (phones)
  2. small tablets (7″ category)
  3. large tablets (10″ and above).

Qualifiers before Android 3.2:

Google’s first attempt at creating qualifiers to separate resources by device was to create a handful of size buckets: small, normal, large, xlarge. Initially, this worked out well as handset devices were in the small/normal category, the first 7″ tablets on the market were large, and the first 10″ tablets were xlarge.

Qualifiers with Android 3.2 onwards:

However, as more and more devices began appearing in the market with new screen sizes and the lines began to blur about where a device might present itself. A new solution to the problem was presented in Android 3.2, in the form of new qualifiers to pick resources based on a devices current width/height or “smallest” width; the latter being a new designation for the devices size by representing it in terms of the width (in density-independent pixels, or dp) of the shortest side of the screen.

Using the new paradigm, it has become common to define small tablets as having a smallest width of 600dp, and large tablets at 720dp, with handsets being everything that falls below that line.

Using qualifiers when minimum support is below 3.2 and target is higher than or equal to 3.2 For applications targeting Android 3.2 or higher as a minimum this new system works well. However, if developers wishing to create an application that runs universal on handsets and tablets are compelled to support a minimum Android version no higher than 2.2, or at best 2.3, then in that case create duplicates of each resource in a directory with the old size qualifier and place it an another directory with a corresponding smallest width qualifier.

E.g. keeping the same dimens.xml file in values-large and values-sw600dp. So the device running on android version lower than 3.2 will take values from values-large and the device running on android version higher than or equal to 3.2 will take values from values-sw600dp

Antrim answered 25/6, 2014 at 6:21 Comment(0)
Q
3

//you need to run this in API level 3.2 and above.

for the <3.2 you need to declare normal values-large and values-xlarge

Quinacrine answered 2/1, 2013 at 7:59 Comment(1)
Do you mean if I set targetSDKVersion to 19 then I need to use values-sw600dp and values-sw720dp and when I target to API below API level 13 then I need to use values-large and values-xlarge. right ?Bedtime

© 2022 - 2024 — McMap. All rights reserved.