Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

EditText error icon and show password missplaced

I have an EditText as password input like this

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

            <EditText
                android:id="@+id/password"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:hint="@string/prompt_password"
                android:imeActionId="@+id/login"
                android:imeActionLabel="@string/action_sign_in_short"
                android:imeOptions="actionUnspecified"
                android:inputType="textPassword"
                android:maxLines="1"
                android:singleLine="true" />

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

It's working, but when there's an error the error icon shwon twice and it's on top of show password icon.

error icon missplaced

My validation code to show the error :

if (success) {
    finish();
    startMainActivity();
} else {
         mPasswordView.setError(getString(R.string.error_incorrect_password));
            mPasswordView.requestFocus();
}
like image 964
Lyan Dwi Pangestu Avatar asked Sep 04 '16 02:09

Lyan Dwi Pangestu


2 Answers

Don't call setError on the EditText, use TextInputLayout's setError()

like image 137
ianhanniballake Avatar answered Oct 21 '22 03:10

ianhanniballake


Same behavior for material version 1.1.0-alpha10, even if you set an error into TextInputLayout. You can avoid it by adding to the TextInputLayout this line :

app:errorIconDrawable="@null"

like image 26
DanMan Avatar answered Oct 21 '22 02:10

DanMan