ProjectStructure

Project structure

New project in android studio is very well organized into set of modules. Each module represents each form factor (Phone, wear, etc..). We can deal with each form factor individually to build independent features for them. Lets know about android project structure of Android Studio.

You can clearly observe towards the left side of the Android Studio. ‘Project’ window shows the files of the current project. The complete project file structure can be viewed in different perspectives listed below:

Prespectives

Out of all these perspectives, Best way to view is via ‘Android’ perspective. Select ‘Android’ perspective and here you can get the good understanding of the complete android project structure. The window consists of 2 folders:

Module

Project folders for a form factor like phone, wear, etc

Gradle Scripts

Files for building, configuring and generating .apk are present here

When the project is created for ‘Phone and tablet’, ‘wear’, ‘tv’ form factors, then the project window will change as shown below.

Form factor is nothing but a form of device on which android operating system runs.

Formfactors

From the above picture we can get to know that there are three modules present which corresponds to three form factors (mobile, tv, wear). When we create project for ‘Phone and tablet’ form factor, the project window will have the following structure which single module named as ‘app’ and ‘Gradle Scripts’ folder.

structure

Lets deal with ‘Phone and tablet’ form factor presently for easy understanding with the basis. Open ‘app’ module by double clicking on it. There are three folders under it namely ‘manifests’, ‘java’, ‘res’.

app

manifests

manifest file of the current project

java

java packages of current project

res

resource files of current project (all xmls, images, etc)

res folder contains all the xml files which act as resources to the front end. This folder is well categorized based on the type of resource files.

res

drawable

contains all the image assets and xml files that support customization

layout

contains all the xml files that represent screens. In short, screen layouts are present here

menu

it keeps all menu xml files that support screen layouts

mipmap

introduced later drawable folder in order to store launcher icons.

values

contains other xml files which help in styling and other stuff.

XML basically contains xml tags in it. The xml tags are arranged in a tree structure. Every tag is a parent tag for the tags appearing inside it. Coming to the screen layouts, every layout file is nothing but an xml file. So all the elements that we see in the screen are nothing but xml tags arranged accordingly.

So next time whenever you see a beautifully designed android screen, remember that those are nothing but xml tags which are beautified by customizing.

Lets take a button as example element. Every button on android screen is nothing but an xml tag with an name as ‘Button’. So whenever we declare a ‘Button’ tag in the xml file, it reflects as real Button on the screen layout. The ‘Button’ tag we declared is referred by an ‘id’. it should be uniquely mentioned as we refer to it couple of times while dealing with it. The text present inside button is static text which comes from ‘strings.xml’ present under ‘values’ folder.

values

Every xml tag needs an unique id to be referred further. And every xml tag can be customized to look according to your design guidelines.

java

java folder, two Java packages are present inside it with the same name but one is for developing and one is for testing. This is the same package name which we gave while creating the project. Inside the package, java classes are present. ‘MainActivity.java’ is the initial activity file present inside the package.

Android screen is nothing but a xml layout file backed by java class file

manifest file in simple terms is an index file for the complete project. It has the record of what all activities are being used in the app. It guides the app on which screen to be shown first when the app is opened. Common stuff like application name, theme of the project, permissions used for the project will be declared in this file.

Gradle Scripts folder contains two ‘build.gradle’ files. One file belongs to complete project and the other belongs to specific module. The module ‘build.gradle’ file includes the information like version of the app, version of the sdks used and compiled, target sdks, applicationId, dependencies (libraries).

Thats all about the sweet android project structure details.

The complete structure of the project will look as shown below:

CompleteStructure

Download  this tutorial

241 total views, 1 views today

Leave a Reply