Do you know that XML file plays an important role in your projects? Have you ever noticed that XML files are the ones that help to store and to transport the data?
In this article, we will discuss XML files and we will understand XML layout files. We will see what is the directory structure of an application in android studio. We will also discuss in which directory the XML file is stored. Let’s get started with understanding XML.
XML stands for Extensible Markup Language. XML is used to exchange data between two applications. It helps two applications to communicate with each other. To store and transport data, we use an XML file. There are certain rules and specifications of XML that come from WWW (World Wide Web). XML is platform independent language. It is a readable language both by humans and machines.
We use tags or marks for writing an XML file. Tags are not limited or pre-defined we can extend these tags, that’s why it is called Extensible Markup Language. Moving forward, let’s understand about XML layout files.
What are XML Layout Files?
XML files are flexible and used to define user-interface layouts for android applications. Making screen layouts becomes very easy with XML. We can make various layouts for various different screen sizes. XML layout files help in maintaining the structure of the file. By default, in XML, we have a Constraint layout in android. Constraint layouts help in the sizing and positioning of widgets very flexibly. It helps in laying out user interfaces very easily because we can position and size widgets with the help of one line of code only. Using constraint layout, animations can also be added to our applications.
Moving Forward, let’s discuss Android Studio. Android Studio is an IDE (Integrated Development Environment). It is developed by JetBrains, and Google provides this for application development.
The Directory Structure of a Project in Android Studio
Whenever we create a new project in Android Studio, the created project is stored under AndroidStudioProjects. Let’s create an application named NinjasWorld and understand directory structure. On clicking your application name, you will see four created directories:
To understand these folders more briefly, let’s discuss them one by one.
Manifest Folder is used for providing information about applications to the android operating system. All data about the version of android, packages, and so on are stored in this folder.
Java Folder stores all the logic related to business. Java folder contains all the .java files, which means the java folder includes files having java and kotlin source code. And it also contains some test files.
Resource Folder consists of four sub-folders named: Drawable, Layout, Mipmap, and Values folders. This folder is responsible for XML layouts (Layout Folder), images (Drawable Folder), and user-interface strings, for example, colors, styles, dimensions (Values Folder), and icons (Mipmap Folder).
Gradle Folder is used for configuring builds. For compiling your project at once, a Gradle folder is required.
Directory in Which XML Layout Files are Stored?
XML layout files are stored in Layout Folder inside Resource Folder, so we can say that XML layout files are stored in Reslayout Directory (res/layout/). The resource folder is responsible for various resources that are used across the application, resources as styling, color, images, and icons.
You will see an activity_main.xml file inside the layout folder, as shown above. This XML file is the main building interface of your application. To change the layout of your application, you must make changes in this XML file.
Frequently Asked Questions
What are Layout Files?
Layout Files are the files that help in structuring the data of a text file.
What is a Markup Language?
A text encoding system consisting of tags in a text document is known as Markup Language.
What are the main features of an XML File?
XML files are platform-independent, which helps them to run on any machine without data loss. XML files are also language independent by which two applications with written in different applications can also communicate with each other.
What is the structure of XML Files?
XML files have a tree-like structure. It contains a root element, branches, and child elements.
Conclusion
In this article, we have discussed XML (Extensible Markup Language) files. We understood about XML layout files. We have also discussed the directory structure of a project in android studio. We also got to know that XML files are stored in the Reslayout directory. If you want to know more about android studio and application development, then you can refer to the articles:
I hope this article helped you a lot in understanding XML. If you are preparing for interviews, then you can read this article XML Interview Questions on our platform Code Studio. You can also consider our Online Coding Courses such as the DSA in Python, C++ DSA Course, DSA in Java Course to give your career an edge over others.