First in the XML layout files layoutwidth and layoutheight are required

First in the xml layout files layoutwidth and

This preview shows page 9 - 16 out of 78 pages.

First, in the XML layout files, layout_width and layout_height are required attributes. Next, you see that each TextView control has a unique id property assigned so that it can be accessed programmatically at runtime. Finally, the textSize property needs to have its units defined. The XML attribute takes a dimension type. The end result differs only slightly from the programmatic method. However, it’s far easier to read and maintain.
Image of page 9

Subscribe to view the full document.

Creating Layouts Programmatically (Cont’d) The layout resource is stored in the res/layout/resource_based_layout.xml file: setContentView(R.layout.resource_based_layout); Now you need only one line of code to display this layout view.
Image of page 10
Creating Layouts Programmatically (Cont’d)
Image of page 11

Subscribe to view the full document.

Organizing Your User Interface All user interface controls, such as Button , Spinner , and EditText , derive from the View class. In Android, there is a special kind of View called a ViewGroup . ViewGroup subclasses are broken down into two categories: 1. Layout classes 2. View container controls
Image of page 12