..
Put aside for a moment the file R.java: In later chapters we will see an example in which the graphics add to our activity and we see that, after compiling, the file will change R.java automatically generating a different code.
We focus therefore our attention main.xml file located in your res / layout of our project. Once you open the file will open the following interface:

The xml we see is the code for the layout and then the structure of our Activity. This file is a kind of guide that tells the device to use the type of layout, graphics and more in the view. When we invoke the method setContentView (R.layout.main) let's just call this file and the device, analyzing it, understand where and how to place all the elements of sight.
Let us now review the xml file to understand the meaning of each statement.
<? Xml version = "1.0" encoding = "utf-8"?>This declaration is a declaration standard only defines the version of XML used (in our case 1.0) and the encoding used (in our case utf-8). We recommend the reader to keep this standard and therefore do not change this initial line.
<LinearLayout xmlns: android = "http://schemas.android.com/apk/res/android" android: orientation = "vertical" Android: layout_width = "fill_parent" Android: layout_height = "fill_parent" >In the first line of code opens a tag type LinearLayout which actually is the name of the layout will use the application. After the opening of this tag are XMLs: Android followed by a URI. This definition has the effect of the document to indicate the tag for the namespace specified in the URI. Since the detailed explanation of XML is beyond the scope of the guide we recommend the reader to deepen the concepts of XML namespaces in the guide centre-equestre-lepuy.com present on and within this page .
Continuing analysis of the code we find that the orientation is defined as a vertical layout and is associated with the width and length value fill_parent. This value tells the device to extend the layout for all the grandeur of the device screen both horizontally and vertically. Ultimately this layout using all the elements we're going to enter, they will be positioned vertically from top to bottom.
Proceeding with the reading list you will find the declaration of an object of type TextView, which is nothing but a text box:
<TextView
Android: layout_width = "fill_parent"
Android: layout_height = "wrap_content"
android: text = "@ string / hello"
/>
</ LinearLayout>
In this case we have linked up to the value wrap_content element that has the effect of extending the item for a height to contain the string you enter.
Finally we set the contents of the TextView with the string denoted by the value in the file hello strings.xml folder res / values.
As the last statement we find the tags of closure of LinearLayout.
| |
ASP Zero (Ebook)
Learning Microsoft ASP and VBScript from scratch. At only 29 €. |
| |
Linux (Course)
Complete guide to open-source system. From 49 €. |
| |
MySQL (Course)
Management of open-source database. From 39 €. |