Assume I have an activity with three different layouts in different resource folders. For example:
layout-land/my_act.xml
layout-xlarge/my_act.xml
layout-xlarge-land/my_act.xml
In different devices and different positions one of them is selected by Android.
How can I find out which one is selected programmatically?
Does Android have any API that returns these layouts to the program?
Edit: Graham Borland's solution has a problem in some situations that I mentioned in the comments.
You could create a
values-<config>
directory for each of your supported configurations. Inside of each of those directories, create astrings.xml
with a singleselected_configuration
string which describes the current configuration. At runtime, fetch the string using the standardgetString
method, which will do the configuration resolution for you and return the correct string for the configuration. This is untested.You can try to repeat this algorithm "How Android Finds the Best-matching Resource" - it's quite simple, especially if you have different layouts only for different screens.