使用超出minSdkVersion的API级别的属性 [英] Using attributes from API level beyond minSdkVersion

查看:261
本文介绍了使用超出minSdkVersion的API级别的属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Android开发的新手,我想知道如果您在大于minSdkVersion的API级别上对XML标签使用属性,会发生什么情况.

I am new to Android development and am wondering what happens if you use attributes on XML tags from an API level greater than your minSdkVersion.

例如具有:

<uses-sdk
    android:minSdkVersion="9"
    android:targetSdkVersion="20" />

然后使用它:

<activity android:logo="@drawable/iconwhatever"></activity>

"android:logo"属性来自API级别11.

The "android:logo" attribute is from API level 11.

在Android Studio中,它会出现以下错误,但是我想知道如果不这样做会发生什么情况:

In Android Studio it gives the following error, but I want to know what could happen if this is left alone:

Attribute "logo" is only used in API level 11 and higher. (Current min is 9)

任何对此的帮助将不胜感激.

Any help regarding this would be greatly appreciated.

推荐答案

安全地忽略不支持的属性.

Unsupported attributes are safely ignored.

从SDK 文档:

在解析XML资源时,Android会忽略当前设备不支持的XML属性.因此,您可以安全地使用只有较新版本支持的XML属性,而不必担心较旧版本在遇到该代码时会被破坏.

When parsing XML resources, Android ignores XML attributes that aren’t supported by the current device. So you can safely use XML attributes that are only supported by newer versions without worrying about older versions breaking when they encounter that code.

这篇关于使用超出minSdkVersion的API级别的属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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