JFDP - Android App Developement Using Java PPT4
JFDP - Android App Developement Using Java PPT4
Understanding the
Layouts
What is Layout???
• An Android layout is a class that handles
arranging the way its children appear on the
screen. Anything that is a View (or inherits
from View) can be a child of a layout. All of the
layouts inherit from ViewGroup (which
inherits from View) so you can nest layouts.
Every View and ViewGroup object supports
their own variety of XML attributes.
Basic XML Attributes in Android
• ID: Any View object may have an integer ID associated with it(see R.java),
to uniquely identify the View within the tree. When the application is
compiled, this ID is referenced as an integer, but the ID is typically
assigned in the layout XML file as a string, in the id attribute. Syntax:
android:id="@+id/my_button“
@ indicates that the XML parser should parse and expand the rest of the
ID string and identify it as an ID resource.
+ symbols means that this is a new resource name that must be created
and added to our resources (in the R.java file).
There are a number of other ID resources that are offered by the Android
framework. When referencing an Android resource ID, you do not need
the plus-symbol, but must add the android package namespace, like so:
android:id="@android:id/my_button"
Attribute Description