Chilly Chan Chilly Chan - 1 year ago 104
Android Question

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

I've been writing some Android apps but I don't really understand when to use

and when to use
. When styles are not being applied the way they're supposed to, I use trial and error and sometimes find that using
instead of
solves the issue but I don't understand why. It'd be great if someone could point me in the right direction. Thanks!

Answer Source

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 namespace, they belong to[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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download