Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Building Android Apps without XML [closed]

Tags:

android

xml

Do I have to use XML to build the interface in Android Apps? I don't like XML and I would rather write the interfaces out in Java.

In iOS, you can write your interfaces using Interface Builder/Storyboards, or you can just write them by hand in code, which I think is better.

Do I have to use XML with Android?

like image 778
Joseph Perla Avatar asked Mar 14 '12 22:03

Joseph Perla


3 Answers

You can avoid the XML (but not the Manifest file : AndroidManifest.xml).

From Android Website :

Every application must have an AndroidManifest.xml file (with precisely that name) in its root directory.The manifest presents essential information about the application to the Android system, information the system must have before it can run any of the application's code. Among other things, the manifest does the following:

You can get more informations here : Create App without XML (try to search before posting)

like image 187
ChapMic Avatar answered Oct 30 '22 17:10

ChapMic


Leaving the manifest aside, you can, of course. All of the XML mumbo jumbo eventually maps down to code, and Android exposes that functionality.

Now, do you really think its better to eschew the XML layouts? Your code, I think, should be worrying about behavioral logic, not presentation logic. The XML facilities allow you to extarnalize most of the presentation logic, so that it doesn't clutter your code.

like image 30
slezica Avatar answered Oct 30 '22 18:10

slezica


I've personally, constructed a large visual library. Windows, ddlb's, date pickers, lists, custom image buttons, text edit areas.. Not a lick of XML.. I've tested layouts on a little phone, and on a 7in tablet. All good.

It can be done, but it's a lot of work. The plus is, my controls look like my controls. They have a flavor to them that is utterly under my control.

Everything is of course abstracted, so when I'm writing "the behavioral logic" that's all I care about.

Oh another plus.. when I take the code to another language (c++, c# or objective c) the apps look the same, because I have the exact same abstraction (with in limits of the languages).

like image 32
baash05 Avatar answered Oct 30 '22 17:10

baash05