<EditText>
element is a View object used to create a user-editable text field. Let's look at a sample XML layout code snippet to demonstrate this
<EditText android:id="@+id/edit_message" android:layout_width="wrap_content" android:layout_height="wrap_content" android:hint="@string/edit_message"/>
In the above sample code snippet, you can see few XML attributes used to setup the properties of <EditText>
.
android:id is used to provide a unique identifier for the view. The at sign (@) is used in android:id, followed by the resource type (id), a slash and resource name (edit_message) to refer any resource object from XML.
android:layout_width and android:layout_height are used to specify the size of the element. Here, wrap_content is provided for these attributes to specify that the size of this view object (here, EditText) should fit the contents of the view.
android:hint is used to default a string to display when the text field is empty. For example, You could have noticed a water mark text in an empty text boxes in few websites. Similar effect can be achieved using this XML attribute. In the given sample code, the default string will be read from a resource file.