Thursday, 27 August 2015

Design of Android Studio- Project view

In this tutorial we will study about the whole interface of android studio. We will start with project view.

Click on Android here you will get different views. Generally Android view or Project view is used many developers. Here, I will tell you about Android view. You can check all other views on yourself.
Here, apps and gradle scripts are the two folders. We won’t require gradle script in the start. So I will tell about it may be after few more tutorials. Expand the folder app.
In the figure shown below, I have expanded all the folders but we don’t need to expand all at the time while preparing apps.
First file is AndroidManifest.xml here all created activities are defined.
Next part is java files. Here we do programming stuff in java in only main activity. ApplicationTest file is created automatically.
Later is res i.e. resource.
First part is drawable. In drawable folder we store all images which are the part of our app.
In activitymain.xml we do xml programming for layout of app.
Further is menu_main.xml this one is for the menu file. This is used for settings and similar purpose. The option for this is available in the upper right part of our layout.
In minmap we store the logo for our application.
Value is the folder in which we store different constants. Here a string is not the variable but wherever it is mentioned is placed by its value defined in these files.
This is the first part of design
Second part is about xml file.

What is layout?

Layout can be considered as a parent and the widgets imposed on it are children. It is the container containing widgets.
There are different types of layouts.
Currently we will go with Relative Layout.
Relative Layout is pre-added, so we do not need to add it in activity.
Whenever we place an object in layout it is placed with respect to/ relative to any other object/objects or the layout itself.

Go to Design view in xml file and pick large text from the widget section.
See the figure carefully. Every object is placed with respect other object
  1.          Widget present at center is placed at horizontal and vertical centers of relative layout
  2.          Widget in upper right section is placed at the most right and top position with respect to layout
  3.          Widget in upper left section is placed with x co-ordinate as left to center widget and y co-ordinate as below by fixed amount of pixels to the top of relative layout
  4.          Widget in bottom left and bottom right section are placed with respect to other parameters

Now, if I select the center widget and delete it then what will happen?
Firstly when we select the center widget then the layout will look like the figure shown below
The other 2 widget which have one co-ordinate (here it is x co-ordinate) dependent on center widget are shown in yellowish color. Now if I delete the center widget then the layout will be how?
Since the parent widget (i.e. deleted widget) is aligned at center for x co-ordinate, the dependent widgets will take center of x co-ordinate for positioning itself.
So, be wise while dealing with relative layout.