shyndman a14fe167cf Documentation cleanup.
I'm updating this CL as I go to fix all the issue we can find.

* Icon lists items now use correct icons, and are rearranged to be consistent.
* Removed HTML comments that were interfering with the Liquid templates.
* Added the benefits list to the docsite-index.
* Capitalized "Design" in Material Design.
* Spec links in icon list now use consistent labels.
* URLs, headings and page titles are now internally consistent within the platform.

PiperOrigin-RevId: 155445665
2017-05-08 16:48:53 -07:00

4.4 KiB

TextInputLayout

TextInputLayout provides an implementation for Material text fields. Used in conjunction with a TextInputEditText, TextInputLayout makes it easy to include Material text fields in your layouts.

Design & API Documentation

Usage

To create a material text field, add a TextInputLayout to your XML layout and a TextInputEditText as a direct child.

<android.support.design.widget.TextInputLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

  <android.support.design.widget.TextInputEditText
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:hint="@string/hint_text"/>

</android.support.design.widget.TextInputLayout>

Note: You can also use an EditText for your input text component. However, using TextInputEditText allows TextInputLayout greater control over the visual aspects of the input text - it allows TextInputLayout to display hint in the text field when in "extract mode" (such as landscape mode).

Common features

TextInputLayout provides functionality for a number of Material text field features. These are some commonly used properties you can update to control the look of your text field:

Text field element Relevant attributes/methods
Label (also called a “Floating Label”) android:hint
app:hintEnabled
Error message app:errorEnabled
#setError(CharSequence)
Password redaction app:passwordToggleEnabled
app:passwordToggleDrawable
Character counter app:counterEnabled
app:counterMaxLength