There are benefits to each. XML gets the benefit of being fast and easy to read and still remaining concise and to the point, while Java typically is very verbose about its coding. But, you cannot create dynamic GUIs with XML and can only code the static part in XML.
Personally, I've wanted XML layout for Java for a long time, and from the perspective, I think that Android has pulled it off beautifully. However, when I run across a GUI problem that requires a variable number of buttons or other components based on some situation, I have to use non-XML layout.
I like XML better for the following reasons:
- It allows for faster development (IMO).
- There is less chance for bugs to crawl in.
- It can adjust layout and resources based on the phone position and locale.
- Not verbose.
I still like using raw Java when a dynamic GUI is needed.
How do you do your GUI layouts?