Layouts and activities

Most Activity classes will have a layout associated with them. The layout will be the "face" of the Activity to the user. In this case our layout will take over the whole screen and provide a list of notes.

Full screen layouts are not the only option for an Activity however. You might also want to use a floating layout (for example, a dialog or alert), or perhaps you don't need a layout at all (the Activity will be invisible to the user unless you specify some kind of layout for it to use).

Open the notepad list.xml file in res/layout and take a look at it. (You may have to hit the xmltab, at the bottom, in order to view the XML markup.)

This is a mostly-empty layout definition file. Here are some things you should know about a layout file:

• All Android layout files must start with the XML header line: <?xml version="1.0" encoding="utf-8"?>.

• The next definition will often (but not always) be a layout definition of some kind, in this case a LinearLayout.

• The XML namespace of Android should always be defined in the top level component or layout in the XML so that android: tags can be used through the rest of the file:


0 0

Post a comment