From d3161450fb6bd461575f0e93fadacea73cc9c51c Mon Sep 17 00:00:00 2001
From: David Friedman
In general, the XML vocabulary for declaring UI elements closely follows the structure and naming of the classes and methods, where element names correspond to class names and attribute names correspond to methods. In fact, the correspondence is often so direct that you can guess what XML attribute corresponds to a class method, or guess what class corresponds to a given xml element. However, note that not all vocabulary is identical. In some cases, there are slight naming differences. For +
In general, the XML vocabulary for declaring UI elements closely follows the structure and naming of the classes and methods, where element names correspond to class names and attribute names correspond to methods. In fact, the correspondence is often so direct that you can guess what XML attribute corresponds to a class method, or guess what class corresponds to a given XML element. However, note that not all vocabulary is identical. In some cases, there are slight naming differences. For
example, the EditText element has a text
attribute that corresponds to
EditText.setText()
.
R.layout.layout_file_name
+R.layout.layout_file_name
.
For example, if your XML layout is saved as main_layout.xml
, you would load it
for your Activity like so:
@@ -214,7 +214,7 @@ set the width or height:
getLeft()
returns 20, that means the view is located 20 pixels to the
right of the left edge of its direct parent.
@@ -282,7 +282,7 @@ Available Resources document.
To measure its dimensions, a view takes into account its padding. The padding is expressed in pixels for the left, top, right and bottom parts of the view. - Padding can be used to offset the content of the view by a specific amount of + Padding can be used to offset the content of the view by a specific number of pixels. For instance, a left padding of 2 will push the view's content by 2 pixels to the right of the left edge. Padding can be set using the {@link android.view.View#setPadding(int, int, int, int)} method and queried by calling @@ -375,7 +375,7 @@ alt="" />
When the content for your layout is dynamic or not pre-determined, you can use a layout that subclasses {@link android.widget.AdapterView} to populate the layout with views at runtime. A subclass of the {@link android.widget.AdapterView} class uses an {@link android.widget.Adapter} to -bind data to its layout. The {@link android.widget.Adapter} behaves as a middle-man between the data +bind data to its layout. The {@link android.widget.Adapter} behaves as a middleman between the data source and the {@link android.widget.AdapterView} layout—the {@link android.widget.Adapter} retrieves the data (from a source such as an array or a database query) and converts each entry into a view that can be added into the {@link android.widget.AdapterView} layout.
-- cgit v1.1