HarshitVaish
10/1/2016 - 7:21 AM

Floating Labels For EditText

Floating Labels For EditText

<android.support.design.widget.TextInputLayout
        android:id="@+id/input_layout_name"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <!-- Wrap edit text here-->
</android.support.design.widget.TextInputLayout>
dependencies {
    compile 'com.android.support:design:24.2.1'
}
// Declare and initialize 
TextInputLayout textInputLayout = (TextInputLayout) view.findViewById(R.id.input_layout_name);

// If error
textInputLayout.setError("Username and password must be greater an 5 characters");

// If no error
textInputLayout.setErrorEnabled(false);