XML in Android Development

In Android Development, as I have already said, you use two languages (mostly), Java and XML. Java is used to make things happen while XML lays everything out.

Its a bit of a parallel to web design, HTML and CSS lays everything out and Javascript tells everyone what to do. Here XML lays everything out Java tells everyone what to do.

XML looks like HTML at first sight but then when you notice that there’s no HTML tag you start to get worried. XML and HTML work in tags:

“html’   “/html’                  (replace the ” with < and ‘ with >)

The first one opens the tag, the second one closes it.

In Android, XML lays out two different types of things: 1. The layout of each screen (Activity) 2. The layout of the app itself in the AndroidManifest.xml.

The layout of each screen starts with your common <?xml> tag and then after that the tags are used as parents and children. The “LinearLayout” tag might come first (the parent) and then inside it would be its children, say an “EditText” tag (a text box) or a “Button”. Then because it is XML, you can add attributes which go inside the tag. These will describe what the object will look like:    android:gravity=”center”   would make it in the middle of the screen.

The AndroidManifest.xml is something slightly different. This states all of the Activities in the app and the “intents”. Intents tell the user before they install the app that it will use certain permissions (maybe accessing the internet).

I hope this tells you something new!



About tech189

Casual blogger on technology, photography, and science at www.tech189.wordpress.com

3 responses to “XML in Android Development”

  1. franciumetc says :

    XML is much older than HTML. It is designed, unlike HTML, to store information, whereas HTML displays it. It therefore has a wider range of uses – HTML is used almost exclusively in webpages but XML is sometimes used in C, Java and other non-web languages.
    I don’t like the way that XML controls the layout – can it be dynamically controlled?
    I wholly approve of the use of XML for the manifest file, though. Manifest files are used in Java primarily to create executable JAR archives. They have the extension .mf or .manifest, and they are written in their own language. I have never quite understood them, perhaps as a result of this unusual language. XML is good for hierarchical information storage, unlike SQL, which simply matches one value to another. In this way it is similar to YAML.

    In HTML DOCTYPE declarations you may have encountered the extension .DTD. This stands for Document Type Declaration or something like that. It is used to give a specific list of tags that can be used in an XML file, and how they are used.
    Do the XML files you mentioned use DTD (or Schema, an alternative to DTD)?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

Janet's Writing Blog

I write southern historical fiction. The novel I'm writing is set in the Carolinas in the 1760s. I blog about my journey as a writer and a reader. Come along for the ride!

The Knightly Reader

Always honored to read and review. Especially at night.


Rock It!

Reymon de Real Photography

Amateur photography by a professional Physical Therapist!

%d bloggers like this: