This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Compared to Apple's Interface Builder and even Windows Mobile 7's graphical design tools the ADT-plugin's Visual Layout Editor is not that mature (yet, I hope). What is your experience with designing user interfaces in Android? Mine is that it can take a lot of time to get it right. If you have a large project, with e.g. 40 Android UI activities (why not) what is your preferred way of creating all those layouts? Do you simply delve into the XML, or do you use some procedural parts, do you reuse stuff, or... do you even use the Visual Layout Editor? Do you know the ADT-team and do you know where it is headed?
Johan Pelgrim, The Netherlands
SCJP 1.4, SCWCD 1.4, SCBCD 5.0
This is very much a personal opinion, but I generally prefer to write user interface layouts by hand.
In Android in particular, I find that developing layouts by hand encourages you to reuse of layout elements. Reusing layout elements improves consistency, which in-turn improves user experience. It also makes maintaining your application much easier. Using the <include> tag in your layout resources gives you significantly more flexibility with the resource loader, since each included layout file is selected separately to the layout file including it. Visual Layout tools tend to make these interactions, and interactions between your layout XML and source code rather difficult. I've found that writing the code by hand lets you mix-and-match XML layouts and widgets created in Java code more easily, something I discuss at more length in the book. With the number of screens you're suggesting (40 odd) there should be a fair amount of commonality, and therefore plenty of opportunity to reuse parts of the layout XML.
As you say: getting a user interface right takes time, but I find it's always something that takes time. I personally enjoy sketching user interfaces out on paper a few times before actually getting to work on them. Paper and pencil serves two purposes for me: it helps me organize my thoughts and ideas on the user interface away from the constraints of the platform I'll be implementing on (in much the same way as many web designers will do much of their work in Photoshop instead of an HTML tool). Secondly: I find it much easier to then figure out what widgets and layouts will be needed, generally by drawing boxes around sections of the layout.
On the ADT plugin specifically: I don't know the ADT team personally, nor where they plan on taking the project.
When I say developing layouts by hand, I mean with XML and Java. Some layouts are more rigid and can be built with just XML, but there are times when you need some Java code. I try to shy away from pure Java code when it comes to Android layouts, opting to load bits of the layout with a LayoutInflator instead and then injecting data as required.
This offers the best of both worlds: you're able to build more complex layouts than you can with just XML, but also don't loose any of the great resource loading magic that Android provides.