Issue
I would like to load dimens.xml based upon the screen size, but use the same colors regardless of screen size.
I have the following directory structure
res
res/values
colors.xml
res/values-small
dimens.xml
res/values-normal
dimens.xml
res/values-large
dimens.xml
res/values-xlarge
dimens.xml
I am new to Android but it seems that the system picks only a single values directory at load time. What this means is that, although I get the dimens.xml from the values-qualifier directory as desired, I have no colors defined.
Is there some way to define certain kinds of values resources that are used for any device configuration, while defining other kinds of values resources on a per-configuration basis?
Solution
That directory structure should work as it is. From the documentation for Providing Resources
Whereas XML resource files in other res/ subdirectories define a single resource based on the XML filename, files in the values/ directory describe multiple resources. For a file in this directory, each child of the resources element defines a single resource. For example, a element creates an R.string resource and a color element creates an R.color resource.
That means that unless you have a particular color in (say) the values-large
directory, the value from values
will be used for it. The granularity is per-resource, and the names of the actual files are unimportant.
Answered By - matiash
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.