..


Sponsored Links

Building graphical interface using the file main.xml

In all previous examples have been provided to the reader the listing for the XML creation and placement of objects. If you remember, when you open the file main.xml can choose to display the listing or XML or the graphical interface with which to build the layout shown in the following screenshot of Activity:

Graphical interface to build a layout XML.

We now try to explain the workings of this simple graphical interface.

To the left of the interface there are two folders:

  • Layouts
  • View
The first contains the types of layouts you can use, while the second contains all the elements that inherit the View class with which you can create the graphical interface.

To add an item to our interface, we're going to make nell'activity, simply select an item and drag it into the black window in the middle of the page. As soon as you release the item within the window, it is placed in the hierarchy of items in the menu on the right.

Obviously each element draggable can be fully customized to change the text content to display to the user, the font used, the position within the window and much more.

Manage the properties of

But how do we know the properties of the item personalized? Again using the interface provided by Eclipse is handy because it's just double-click the item in the menu on the right to open at the bottom, a new tab Properties.

Properties for the selected item.

This tab contains a list of all the properties that you can customize about the selected item. In our example we have selected an object of type Button and, as we can see, the list of properties is very long.

To set the value of some property just click on the side of the property itself and enter the desired value. For example: posizioniamoci in the Background property (which identifies the background color of the button) and insert the following string: # 2563EA. As you may have guessed is necessary to indicate the color associated with the hexadecimal code.

That said, once the file is saved, if we move we will find the XML in Listing new property set to the value entered.

At this point the reader may ask: but why was not immediately presented this method? The reason lies in the fact to accustom the reader to the XML language and be able to understand, even just reading the listing, the organization of the interface. This is important because XML is the master key to the development and optimization of the application based on Android. Also, if the player wants to deepen the development of applications even on the official Android, will only listings related to the layout of the XML activity and is therefore essential to understand the meaning of various tags and attributes present.

Help develop applications for Android
E-Learning
ASP Zero (Ebook) ASP Zero (Ebook)
Learning Microsoft ASP and VBScript from scratch. At only 29 €.
Paint Shop Pro (First) Paint Shop Pro (First)
Web graphics and photo editing with Corel PSP known. From 49 €.
Webmaster Base (First) Webmaster Base (First)
Create a Web site from scratch. Starting from 29 €.
Sponsored Links