Reputation: 265
Hi,
How to use XML code instead of Android code to be used regarding UI development? In what manner XML is different from ordinary Android code?
Upvotes: 2
Views: 129
Reputation: 864
Its much easier to develop UI using XML than by JAVA code mainly due to visual Drag-and-Drop feature. But by XML way of laying out views is Static in Nature but by Java code it can made to work during Runtime(may be adjusted to different conditions). So it is recommended that part of the layout which you think, undergoes no change in time should be implemented by XML and vice-versa by JAVA coding. Also static UI by XML can be overrided by JAVA cod during runtime as per requirment.
Upvotes: 2
Reputation: 3966
Basically, if you've static elements in your layout, it's better to use XML. If your layout has a property to change itself dynamically, then it's better to go for Java. When it comes to usefulness as such, using XML is a bit better because you can easily re-configure your XML when compared to the dynamically running code. Finally, designing is a matter of choice and opinion.
Upvotes: 2
Reputation: 8141
Read this ,you will get your answer :
http://developer.android.com/guide/topics/ui/declaring-layout.html
Upvotes: 0