Our main layout is a relative layout and contains a text view saying Hello world!. Now let's add a new component. The easiest way to do this is by using the graphical editor, so open the Design tab. Select a component and drag it into the layout preview; for example, navigate to the Person Name component in Text Fields and place it below the text view.
In the Component Tree view, there is now a new editText
object. Keep the text field selected to examine its properties loaded in the Properties inspector. Let's change some of them and observe the differences in the layout preview and in the component tree:
layout:width: This option will adapt the width of the field to its content. Its current value is
wrap_content
. Change it tomatch_parent
to adapt it to the parent layout width (the root relative layout).hint: Type
Enter your name
as the hint of the field. The hint is a text shown when the field is empty to indicate the information that should be typed. As the field has...