When a GUI is displayed in the Graphical Layout editor, you can use the Properties window at the bottom of the Outline window to configure the selected layout’s or component’s properties without editing the XML directly. To select a layout or component, either click it in the Graphical Layout editor or select its node in the Outline window (Fig. 2.14).
You should rename each layout and component with a relevant name, especially if the layout or component will be manipulated programmatically (as we’ll do in later apps). Each object’s name is specified via its Id property. You can use the Id to access and modify a component without knowing its exact location in the XML. As you’ll see shortly, the Id can also be used to specify the relative positioning of components in a RelativeLayout
.
Select the RelativeLayout
, then at the top of the Properties window set its value to
@+id/welcomeRelativeLayout
The +
in the syntax @+id
indicates that a new id (that is, a variable name) should be created with the identifier to the right of the forward slash (/
). Next, select the TextView
and set its Id property to
@+id/welcomeTextView
The Properties window should now appear as in Fig. 2.15.