7 Replies - 8735 Views - Last Post: 23 June 2012 - 08:40 AM

#1 Dogstopper  Icon User is online

  • The Ninjaducky
  • member icon



Reputation: 2857
  • View blog
  • Posts: 10,960
  • Joined: 15-July 08

[Discussion] XML or Coded GUIs?

Post icon  Posted 01 February 2011 - 04:04 AM

There are two ways in Android applications that you can create GUIs - one is through XML coding and the other is simply like normal Java code. However, Google and most Android developers like to use XML to manage their resources and layout. There are a few people though that would rather use hand coded things.

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?

Is This A Good Question/Topic? 0
  • +

Replies To: [Discussion] XML or Coded GUIs?

#2 SpeedisaVirus  Icon User is offline

  • Baller
  • member icon

Reputation: 114
  • View blog
  • Posts: 855
  • Joined: 06-October 08

Re: [Discussion] XML or Coded GUIs?

Posted 01 February 2011 - 09:22 AM

I preferred the XML approach on Android. Seemed far less cumbersome to get the same results. Sometimes you just have to code it directly though. Having the option is nice.
Was This Post Helpful? 0
  • +
  • -

#3 Sergio Tapia  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1251
  • View blog
  • Posts: 4,168
  • Joined: 27-January 10

Re: [Discussion] XML or Coded GUIs?

Posted 01 February 2011 - 09:39 AM

I've never coded for the Android, but is the XML layout system similar to the XAML layout system of WPF/WP7?
Was This Post Helpful? 0
  • +
  • -

#4 Dogstopper  Icon User is online

  • The Ninjaducky
  • member icon



Reputation: 2857
  • View blog
  • Posts: 10,960
  • Joined: 15-July 08

Re: [Discussion] XML or Coded GUIs?

Posted 01 February 2011 - 09:45 AM

I don't even know XAML, so I can't compare the two, but I can tell you that all the elements, strings, images, and other resources can be provided with XML and thus be compatible in either vertical and horizontal modes.
Was This Post Helpful? 0
  • +
  • -

#5 bflosabre91  Icon User is offline

  • go sabres

Reputation: 105
  • View blog
  • Posts: 1,439
  • Joined: 22-February 08

Re: [Discussion] XML or Coded GUIs?

Posted 01 February 2011 - 10:21 AM

yeah, xaml is pretty similar to xml for android. different control types and all that but they do the exact same thing. im not sure what the difference is for it to add the A is xaml but the idea of them is the same. and i love it but it still is nice to be able to create on the fly because sometimes you need to. but i like having the UI separate from the actual code logic.
Was This Post Helpful? 0
  • +
  • -

#6 UziTech  Icon User is offline

  • D.I.C Head

Reputation: 7
  • View blog
  • Posts: 64
  • Joined: 26-October 10

Re: [Discussion] XML or Coded GUIs?

Posted 02 February 2011 - 07:19 AM

I agree XML is faster and easier to code, but I usually code my GUI in java. It seems like I can debug faster when all, or most, of my code is in one file. Plus when you have a bug in your XML eclipse usually wont find it, because most likely the error is in the attribute values.
Was This Post Helpful? 0
  • +
  • -

#7 Creator347  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 09-April 12

Re: [Discussion] XML or Coded GUIs?

Posted 09 April 2012 - 04:07 AM

I like to create static UI in XML only, as it's easier and saves a lot of time. For the dynamic part, well we have no other option than to use Java coding. It's what Android officials says too(I've read it on Android dev blogs).
Was This Post Helpful? 0
  • +
  • -

#8 Benzoate  Icon User is offline

  • D.I.C Head


Reputation: 51
  • View blog
  • Posts: 230
  • Joined: 29-February 12

Re: [Discussion] XML or Coded GUIs?

Posted 23 June 2012 - 08:40 AM

I personally prefer to use XML because it is easier to just scan over and read, also it is very easy to get it to the screen size and monitor rotations of the android device... On the other hand, I've never used Java code for android GUI, but I have used it for regular programs (ex: calculators), and I found it quite satisfying to use, but sometimes very annoying.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1