Android SDK offers to developers to write layouts in xml files or directly in java code. I have read about it and everyone says that xml are easier to maintain and simplyer
One primary factor to decide where to declare a UI component is it's behavior during the app life cycle. If it's static I'd declare all attributes needed in XML, if it changes according to the user interaction I'd have to implement it in the activity.
I would go for XML as much as possible for the benefits mentions above like coherence, better management for various screen sizes, localization, resource management etc.,