Android Development: Using XML Layout vs. Java Layout

0 Erinç Argımak · January 29, 2015
Hey all. In the Android App Development series on video 13, Bucky gets rid of the default xml layout on the main activity class and starts building a layout on java. Does this have any advantage over XML? Because the XML editor on Android Studio lets us do what he does in two videos in just seconds. So again, what's the difference exactly?

Post a Reply

Replies

Oldest  Newest  Rating
0 Erinç Argımak · January 29, 2015
Thanks a lot for the answer Mike. So if I were to use a constant background that should remain throughout the activities, I could use either of them right?
+1 Mike Conroy · January 29, 2015
I don't have that much experience with Android but I'll throw in my two cents anyway.

There isn't a huge difference between using the xml editor and building the layout programmatically through Java.
The advantages of using the XML are you can use the visual editor and quickly see what a layout looks like and each component will then need to be referenced in the code.
When building a layout in Java it allows for more dynamic layouts, if you have a page that isn't always going to have the same components on and could change depending on other factors then doing it programmatically makes it easier to do this (it could still be done in XML). 
  • 1

Java / Android Development

107,307 followers
About

Very popular language used to create desktop applications, website applets, and Android apps.

Links
Moderators
Bucky Roberts Administrator