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

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

问题描述

我是 Android 开发新手,想知道如果您在 API 级别高于 minSdkVersion 的 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天全站免登陆