android tutorial - How to use textinputlayout in android | Developer android - android app development - android studio - android app developement



How to use textinputlayout in android

Make sure the following dependency is added to your app's build.gradle file under dependencies:

compile 'com.android.support:design:25.3.1'
click below button to copy code from our android learning website - android tutorial - team

Show the hint from an EditText as a floating label when a value is entered.

<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/form_username"/>

</android.support.design.widget.TextInputLayout>
click below button to copy code from our android learning website - android tutorial - team

For displaying the password display eye icon with TextInputLayout, we can make use of the following code:

<android.support.design.widget.TextInputLayout
    android:id="@+id/input_layout_current_password"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:passwordToggleEnabled="true">

    <android.support.design.widget.TextInputEditText

        android:id="@+id/current_password"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="@string/current_password"
        android:inputType="textPassword" />

</android.support.design.widget.TextInputLayout>
click below button to copy code from our android learning website - android tutorial - team

where app:passwordToggleEnabled="true" & android:inputType="textPassword" parameters are required. app should use the namespace xmlns:app="http://schemas.android.com/apk/res-auto"


Related Searches to How to use textinputlayout in android