Home Features Current 10 things every Android developer needs to know - 5. XML layouts
10 things every Android developer needs to know - 5. XML layouts
Written by Carl Whalley   
Friday, 20 November 2009 09:00
Article Index
10 things every Android developer needs to know
1. Support
2. An IDE
3. Java
4. Graphic design
5. XML layouts
6. The Market
2. An IDE
8. OS Versions
9. The App Lifecycle
10. DDMS
All Pages

5. XML layouts

Separate UI from code.

The technology behind webpages is what drove the explosive growth of the internet from the start. All that was sent from the server to the browser were the instructions needed to recreate the page, not the page itself. Not only did this minimise bandwidth, it also allowed the layouts to be marked up with additional data describing the pages themselves. XML is now ubiquitous in computing. Android took XML and used it as a way to describe the physical layout of its UI components in a way similar to HTML for the web. The huge advantage this gives is the separation of the apps logic from its presentation. This is an idea you encounter over and over again, especially in server based webapps, but it's never been widespread on mobile phone development before.

The old way was to entrench the layout instructions directly in the code, so this made changes very cumbersome and error-prone. Some other benefits arise nicely too - internationalisation, for example, is now a breeze as you can ship different versions of the XML layout without changing the code that uses them.

Android allows you to mix and match these approaches. You can still get at the contents of the layouts in code, once loaded from XML, for any run time tweaks you need, you can stick to the XML-only approach or indeed you can ignore XML completely and do it all manually..

The reason this is an important Android skill to know is because once familiar with them you can rapidly create, or prototype, complex UIs which behave they way the final app should. There are only a few to deal with, and their use is demonstrated in the source of the sample apps which ship with the SDK and online. They include:

Knowing the UI architecture - the View hierarchy in particular - is also pretty much essential to successful Android app development, but you soon get that "aha!" moment after working with it for a while, when everything slots into place.



 

Comments  

 
0 #5 cousinHub 2009-12-10 06:54
I liked this part in part 8 (OS versions):

Android releases are named after desserts, so we had Cupcake (1.5), Donut (1.6) and Eclair (2.0), the next two are rumoured to be Flan and Gateaux - in case you hadn't spotted it, there's an alphabetic progression there
Quote
 
 
0 #4 Robert Lilly 2009-12-09 16:26
Awesome article. Now I'm really glad I learned to develop on Android for my augmented reality app instead of some other mobile system. And today I'm going to an interview for an Android developer position.
Quote
 
 
0 #3 Matt Kanninen 2009-12-04 01:32
Preach it brother!
Quote
 
 
0 #2 André 2009-11-24 06:31
Thanks for this article :) I'm sure this will help a lot of Android fans to start their own little project.

For graphics I'm a fan of Inkscape now. It's an awesome piece of software. Especially for doing games and similar stuff. All graphics of my own game Puzzle Blox have been created with Inkscape. Thumbs up!
Quote
 
 
+2 #1 Jeff Watson 2009-11-20 22:10
Great article. I found item #8 Dalvik Debug Monitor Server very useful!
Quote
 

Add comment


Security code
Refresh


Copyright © 2010 Android Academy. All Rights Reserved. Privacy statement. Sitemap.
Android Academy is not associated with Google in any way. All trademarks acknowledged.