Reputation: 2555
I have added widget functionality to my app, which is compatible with older versions of Android (back to 1.6). Widgets in Android 3.1+ support the xml tag resizeMode which is a very useful feature and I'd like to allow users to resize their widgets.
But I'd like to still be backwards compatible with 1.6 (or 2.1 would be good enough too).
How can I do this? Can I have selective xmls?
Currently I am tagetting 1.6.
Thanks!
Upvotes: 3
Views: 1330
Reputation: 6469
I also thought this would work, and created folder xml-v12 and in it widget_info.xml . In XML editor I am getting:
error: No resource identifier found for attribute 'resizeMode' in package 'android'
Is that because I'm using Google API v7? Will the widget project be backward compatible if it's replaced with Google API v12?
Upvotes: 0
Reputation: 234807
You can put resources that are intended for more recent API levels in resource directories that are qualified by the minimum API level supported. For instance, you could have the 1.6 version of the xml files in res/layout and put the 3.1+ versions in res/layout-v12 (the "-v12" resources will only be considered when running under Android 3.1 and later, regardless of what the target level is). You can apply these qualifiers (as described here) to any resource type, not just layouts.
Upvotes: 2