|
Page 6 of 11
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
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
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!
RSS feed for comments to this post.