The text-based editor
Change the graphical editor to the text editor by clicking on the Text tab:
The Toolbar panel is the same as that on the graphical editor. The Preview window displays the layout, but it cannot be changed. To do that, you should use the Design tab instead. The components are added to the layout using their XML declarations. The properties are also configured using XML declarations. Like the graphical editor, the text editor contains two XML elements: a relative layout as the root element and the text view element inside the root layout.
The XML tag names define the type of component that we are declaring. For the relative layout, we use the RelativeLayout
tag, and for the text view, we use the TextView
tag. We can add properties to the elements by including attributes in the XML tags. For example, the text view in our main layout has three properties:
android:layout_width
, with thewrap_content
value: This property sets the element width inside its parent element. The...