0

Currently in Android development it is quite common to start developing new version specially for Android Tablet. (Usually it is not additional layouts for tablet but fully new app as logic for managing fragments is quite different from logic that mobile phone version has started with.)

In out team we have Android resources values in res/values folder, and particularly dimension definitions inside dimens.xml

The problem came to light when this Tablet version is said has to work on phone as well.

Android supposes that alternative resources are put into e.g. values-small, values-normal, values-large, values-xlarge

see Providing Resources article, e.g. locally sdk/docs/guide/topics/resources/providing-resources.html

First it is not said explicitly in docs, but I assume that is inside is values actually values-normal i.e. default values for default screen size with default density (that is mobile phone) Is this suggestion right?

Then without moving of all values intovalues-xlarge (because they are actually were designed with Tablet in mind), how to redefine (or "override") values in particular dimensions inside dimens.xml ?

I can't move because there are a lot of files, and some are under development.

screen-ranges

pic from Supporting Multiple Screens e.g. sdk/docs/guide/practices/screens_support.html

Related SO questions:

UPDATE-1 values is not the same as values-normal, as value put into value-small will be read for xlarge Configuration (when there is no other configurations)

Community
  • 1
  • 1
Paul Verest
  • 60,022
  • 51
  • 208
  • 332

2 Answers2

1

I can't move because there are a lot of files, and some are under development.

As you have already answered yourself, to solve this you need to move the files, so you just need to bite the bullet and get on with it. The "under development" files then need to be placed in the appropriate location when they are ready.

Assuming you are using a code management system like Git, moving the files is no big deal - they still retain all their version history for example.

zmarties
  • 4,809
  • 22
  • 39
1

First it is not said explicitly in docs, but I assume that is inside is values actually values-normal i.e. default values for default screen size with default density (that is mobile phone) Is this suggestion right?

No. res/values/ simply does not qualify on screen size.

Then without moving of all values intovalues-xlarge (because they are actually were designed with Tablet in mind), how to redefine (or "override") values in particular dimensions inside dimens.xml ?

Have one of every value in res/values/. This will be used, by default, on all screen sizes.

Then, in other resource sets, like res/values-large/, provide alternative definitions for select resources, where those alternatives are needed at that stated screen size or larger.

And, you may wish to consider switching to -swNNNdp and kin over the original set of screen size buckets, for more flexibility.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • -swNNNdp configuration qualifier is since API level 13. – Paul Verest Sep 11 '14 at 12:41
  • @PaulVerest: Correct. However, there are very few `large` or `xlarge` screen devices running less than API Level 13. – CommonsWare Sep 11 '14 at 12:43
  • For confirmation: Do you say that I don't need to move to `res/values-large/` but to redefine some values in `res/values-normal/`? – Paul Verest Sep 11 '14 at 12:46
  • @PaulVerest: I have no idea, as I did not write your app. I am merely answering your specific questions regarding the role of `res/values/` and how to override values for sizes. Since the size qualifiers are for a certain size **and larger**, you tend to put your smaller-size values in `res/values/` and override for larger sizes as needed. If you are supporting `small` screen devices, but want different resources for `normal` and larger devices, put the `small` ones in `res/values/` and the `normal`-or-larger ones in `res/values-normal/`, for example. – CommonsWare Sep 11 '14 at 12:50