Nikolay Nikolay - 4 months ago 10
Android Question

What's is the real purpose of having an XML file in Android?

folks. I'm beginning Android development and all of the tutoring videos constantly mention XML file. I looked up the meaning of XML which says:"XML was designed to describe data." But WHY is XML needed in Android and in general(please explain in simple understandable words)? Is there any way to create projects w/o XML file? Thanks in advance!


According to Android documentation:

The advantage to declaring your UI in XML is that it enables you to better separate the presentation of your application from the code that controls its behavior. Your UI descriptions are external to your application code, which means that you can modify or adapt it without having to modify your source code and recompile. For example, you can create XML layouts for different screen orientations, different device screen sizes, and different languages. Additionally, declaring the layout in XML makes it easier to visualize the structure of your UI, so it's easier to debug problems.

Using Android's XML vocabulary, you can quickly design UI layouts and the screen elements they contain, in the same way you create web pages in HTML — with a series of nested elements.