Issue
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.
pic from Supporting Multiple Screens e.g. sdk/docs/guide/practices/screens_support.html
Related SO questions:
- Different GUI on phone and tablet, but same app problem
- Supporting resources for tablets and mobiles
- Which resource structure to use for both Android tablets and mobiles?
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)
Solution
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.
Answered By - CommonsWare
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.