Difference Between Android: and App: Prefix in Android Xml

Difference between android: and app: prefix in Android XML?

android is usually used for attribute coming from Android SDK itself.

app is often used if you are using the support library.

You may also see other namespaces if you are using custom views (of your own or form a library).

Here is some extra information: http://developer.android.com/training/custom-views/create-view.html#customattr

Android Layout - when to use app: vs android:?

You are talking about custom namespace.In android we can create custom views in additional to already available views.
As per in Google developer docs..
To add a built-in View to your user interface, you specify it in an XML element and control its appearance and behavior with element attributes. Well-written custom views can also be added and styled via XML. To enable this behavior in your custom view, you must:

Define custom attributes for your view in a resource element
Specify values for the attributes in your XML layout
Retrieve attribute values at runtime
Apply the retrieved attribute values to your view

Once you define the custom attributes, you can use them in layout XML files just like built-in attributes. The only difference is that your custom attributes belong to a different namespace. Instead of belonging to the http://schemas.android.com/apk/res/android namespace, they belong to http://schemas.android.com/apk/res/[your package name]

So for if you use default views you can use android namespace and if you want to set and use attributes for custom view you can define your own name.

Refer this

What is the 'app' Android XML namespace?

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.

In this case, the appcompat-v7 library uses custom attributes mirroring the android: namespace ones to support prior versions of android (for example: android:showAsAction was only added in API11, but app:showAsAction (being provided as part of your application) works on all API levels your app does) - obviously using the android:showAsAction wouldn't work on API levels where that attribute is not defined.

What is an Unbound Prefix in Android Studio/Java/XML?

It means that you're using an XML namespace prefix (such as android: and app: on the shown attribute names) without having declared it.

Add

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

to element (or any of its ancestors) that uses the android or app namespace prefixes.

What differences between android:actionViewClass and app:actionViewClass?

android is usually used for attribute coming from Android SDK itself.

app is often used if you are using the support library.

You may also see other namespaces if you are using custom views (of your own or form a library).
ref:-Difference between android: and app: prefix in Android XML?

Difference between colorPrimary with android: or without in themes.xml

The one with the android: prefix is defined in the Android SDK, the other one is defined in your app. You can change the value of your color, but you should't be able to change the system one (I don't even know where it is used).



Related Topics



Leave a reply



Submit