Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
186 views
in Technique[技术] by (71.8m points)

android - Using attributes from API level beyond minSdkVersion

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.

For example having:

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

And then using this:

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

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

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.

question from:https://stackoverflow.com/questions/26367537/using-attributes-from-api-level-beyond-minsdkversion

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Unsupported attributes are safely ignored.

From SDK documentation:

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...