Saturday, March 3, 2012

Layouts and Properties

The Android SDK provides a graphical layout editor that allows developers to drag and drop many common objects like buttons, text fields and images.
To navigate to your layouts, open the Package Explorer and expand your project. Navigate to and expand the res (resources) folder, expand layout and double click the .xml file. In the graphical layout you'll see the name of your project and a TextView. To the left of the activity there are many items you can drag into the editor.
Graphical Layout

To the right of the Graphical Layout tab there is a tab called main.xml. The .xml file holds information about objects like properties, color and text of certain objects. Using the .xml files can be useful when searching for the ID of an object or for quickly changing the text or color. The default layout created is a portrait layout. Although all objects in the portrait layout will exist in both portrait and landscape, many of them will be cut off in landscape view. In order to create a file to organize objects specifically for landscape create a folder under res called "layout-land" and copy your layout .xml file from the "layout" folder. The layout land folder allows you to place objects just for landscape orientation.

The properties of an object can be found in the .xml file, but to add new properties it is easiest to use Properties. You can get to properties by find the Properties icon or the Outline icon. The Outline outline shows all objects and by double clicking on a specific one you will be given a list of properties. If an object is selected in the graphical layout and the Properties are open, you will see the properties for that object. There are numerous properties you can set for an object. By using these properties you can specify many details of an object to make your application even better.

No comments:

Post a Comment