Reputation: 113
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"
If someone can explain what's the meaning of the namespaces(android , app , tool) in the XML files? is each word defines different library?
As I know ,in XML files the URI is just a string which gives a unique definition to the namespace , so how does the android app connect the namespace to the library?
Let say we gave the "android" word its default namespace , how come that in different elements we can choose different attributes? is each element(view item) has its unique attributes?
Upvotes: 3
Views: 2274
Reputation: 20930
The app
namespace is not specific to a library, but it is used for all attributes defined in your app, whether by your code or by libraries you import, effectively making a single global namespace for custom attributes - i.e., attributes not defined by the android system.
the appcompat-v7
library uses custom attributes mirroring the android:
namespace ones to support prior versions of android.
The tools namespace is a specially recognized namespace by the Android tools, so all the attributes you define on view elements in the tools-namespace will be automatically stripped when the application is packaged and there is no runtime overhead.
Reference to this answer.
android:text
--> what you would see while running the app.
tools:text
--> what you would see just on preview window (when you need to design layout, but won't it to see on layout in app).
Upvotes: 2