Enabling errorEnabled and passwordToggleEnabled in TextInputLayout

I want to set both errorEnabled, and passwordToggleEnabledtrue to TextInputLayout, but it seems that the two cannot coexist, because one spans the other, like this.

I want to do this because I check the password field to meet certain criteria, and I want the user to be able to see both the error message and the password that was entered.

This is my code:

<android.support.design.widget.TextInputLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:counterEnabled="true"
    app:errorEnabled="true"
    app:passwordToggleEnabled="true">

    <android.support.design.widget.TextInputEditText
        android:id="@+id/password_input"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="@string/password"
        android:inputType="textPassword" />

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

Is it possible to move the PasswordToggle icon to the left of the exclamation mark? Or do I need to create a custom option and use it instead of the passwordToggle icon?

+4
source share
2 answers

setError() TextInputLayout TextInputEditText

XML

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

    <android.support.design.widget.TextInputEditText
        android:id="@+id/password_input"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="Password"
        android:inputType="textPassword" />

    if(password_input.getText().toString().equals(""))
        ti_input.setError("Enter Password");
    else
        ti_input.setError(null);
+1

. setError() EditText, TextInputLayout setError()

0

Source: https://habr.com/ru/post/1692040/


All Articles