Android – How to use TextInputLayout in new android design library

androidandroid-design-library

Recently google introduced new Android Design Library in that how to use TextInputLayout field to enable the Floating Hint feature of EditText.

Not much guidance is available here.

This page says

you can now wrap it in a TextInputLayout

But No idea because smart prediction (Ctrl+SPACE) doesn't predicts any attributes to the TextInputLayout. So my questions are:

How do we get hold of the EditText underlying this component?

How can we get data from EditText?

Best Solution

TextInputLayout extends ViewGroup class. So which means that you have to wrap your EditText in a TextInputLayout.

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

     <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="hint"
        android:id="@+id/editText1" />

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