简体   繁体   中英

What is the meaning of such lines like xmlns:app="http://schemas.android.com/apk/res-auto" in android xml file?

xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"

When you want to import attributes in AndroidManifest.xml you have to kind of import their libraries. which you can then access by their prefixs {android:,tools:,app:} Example of of usage are

android:name="yourpackege.App"

tools:overrideLibrary="yourpackege.App"

app:showAsAction="never"

In the above examples attributes being

android:name, tools:overrideLibrary, app:showAsAction

Of course every single prefix has many more attributes for example

android:name,android:theme,android:value

Kindly note though that

The app namespace is not specific to a library, but it is used for all attributes defined in your app readhere

Just to test the explanation above if you remove lets say xmlns:android="http://schemas.android.com/apk/res/android" and rebuild your android application, you will get and error that looks something like在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM