4

When developing android, we usually use xml when developing a layout file.

example)

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
...

I have a query at that point. How to access http://schemas.android.com/apk/res/android ?

As I found some information. I know that is not a URL, it is URI. So can not access through the internet. Then where is namespace information? How can access that information?

qtmfld
  • 2,916
  • 2
  • 21
  • 36
Kang
  • 75
  • 1
  • 9
  • Do you want to access to RelativeLayout in your code I am right? – Mustafo aka Shokhrukh Makmudov Sep 19 '20 at 15:03
  • 2
    "How to access http://schemas.android.com/apk/res/android ? -- you don't. There has never been a Web page at that URL. "Then where is namespace information?" -- what do you mean by "namespace information"? – CommonsWare Sep 19 '20 at 15:20
  • This may help: https://stackoverflow.com/questions/7119359/why-this-line-xmlnsandroid-http-schemas-android-com-apk-res-android-must-be – null_override Sep 19 '20 at 17:49
  • The namespace defines the attribute names within the XML. If you are looking for information as to their use you might look at the _XML Attributes_ and _Inherited XML attributes_ sections in the [Android API reference](https://developer.android.com/reference?hl=en). e.g. [TextView#xml-attributes](https://developer.android.com/reference/kotlin/android/widget/TextView?hl=en#xml-attributes) – Shazbot Sep 19 '20 at 18:15

1 Answers1

3

The following URI is a namespace name, according to Namespaces in XML 1.0 (Third Edition).

http://schemas.android.com/apk/res/android

In section 3 Declaring Namespaces, it is stated that:

The namespace name, to serve its intended purpose, SHOULD have the characteristics of uniqueness and persistence. It is not a goal that it be directly usable for retrieval of a schema (if any exists).

Some XMLs have no schema. In such XMLs, you can't have it.

The goal of namespace names is to avoid collisions in element names and attribute names. XMLs use URIs as namespace names for their uniqueness and persistence.

qtmfld
  • 2,916
  • 2
  • 21
  • 36