XML is working good with:
xmlns:app="http://schemas.android.com/apk/res-auto"
but can't see max characters with
xmlns:app="http://schemas.android.com/tools"
which is completed by Android Studio auto .
Here is my XML:
<com.rengwuxian.materialedittext.MaterialEditText
android:id="@+id/remark_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
app:met_maxCharacters="20"
app:met_baseColor="@color/black"
app:met_primaryColor="@color/white" />
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 xmlns attribute specifies the xml namespace for a document. Note: The xmlns attribute is required in XHTML, invalid in HTML 4.01, and optional in HTML5.
An XML namespace is a collection of names that can be used as element or attribute names in an XML document. The namespace qualifies element names uniquely on the Web in order to avoid conflicts between elements with the same name.
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). Thanks.
Xmlns stands for 'XML Namespace'
(For further details see https://en.wikipedia.org/wiki/XML_namespace)
The namespace 'schemas.android.com/tools' is for specifying options to build the app by Android Studio, and are not included in the final app package
The namespace 'schemas.android.com/apk/res-auto' is used for all custom attributes - defined in libraries or in code. See this answer for details.
Note that any prefix can be used for a namespace, it is not mandatory to use 'app' for schemas.android.com/apk/res-auto. But the same prefix must be used when defining the custom attributes in the document, otherwise an error will be shown.
So, because met_maxCharacters is a custom attribute, it is shown when the 'schemas.android.com/apk/res-auto' namespace is used, and not with
'schemas.android.com/tools'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With