我如何使用新的XML属性和与较旧的Andr​​oid版本兼容? [英] How can I use the new xml attributes and be compatible with older Android versions?

查看:185
本文介绍了我如何使用新的XML属性和与较旧的Andr​​oid版本兼容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我添加窗口小部件的功能,我的应用程序,这是与旧版本的Andr​​oid(回1.6)兼容。在Android部件3.1+支持XML标签 resizeMode 这是一个非常有用的功能,我想允许用户改变他们的小工具。

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.

不过,我想还是向后兼容1.6(或2.1就足够好太)。

But I'd like to still be backwards compatible with 1.6 (or 2.1 would be good enough too).

我怎样才能做到这一点?我可以有选择性XML的?

How can I do this? Can I have selective xmls?

目前,我tagetting 1.6。

Currently I am tagetting 1.6.

谢谢!

推荐答案

您可以把原打算用于由支持的最小API级别资格在资源目录更近的API级别的资源。例如,你可以有1.6版本在res /布局的XML文件,并把在res /布局V12(以下简称-v12资源只会被认为是3.1+版Android 3.1下运行以后,无论何时什么目标电平是)。您可以将这些限定词(如描述这里)的任何资源类型,不仅仅是布局。

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.

这篇关于我如何使用新的XML属性和与较旧的Andr​​oid版本兼容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆