EditText setError icon and endIconMode are fused

Viewed 157

As mentioned in the title, my setError icon and endIconMode are fused in one

Here is the problem

Basically i want the endIconMode a little bit on the left, or on the right. How can i do this?

Here is the Java:

 private void userLogin() {
            String password = passwordEditText.getText().toString().trim();

         if (password.length() < 6) {
            passwordEditText.setError("Erorr Message" );
            passwordEditText.requestFocus();
            return;
        }

Here is the xml:

 <com.google.android.material.textfield.TextInputLayout
        android:id="@+id/textPasswordField"
        style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginStart="32dp"
        android:layout_marginLeft="32dp"
        android:layout_marginEnd="32dp"
        android:layout_marginRight="32dp"
        android:hint="Inserisci la Password!"
        app:boxBackgroundMode="outline"
        app:boxCornerRadiusBottomEnd="16dp"
        app:boxCornerRadiusBottomStart="16dp"
        app:boxCornerRadiusTopEnd="16dp"
        app:boxCornerRadiusTopStart="16dp"
        app:endIconMode="password_toggle"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.55"
        app:startIconDrawable="@drawable/icons8_key_24">

        <com.google.android.material.textfield.TextInputEditText
            android:id="@+id/passwordEditText"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:inputType="textPassword" />

    </com.google.android.material.textfield.TextInputLayout>
1 Answers

One quick solution is to move the error message to left using padding.

<com.google.android.material.textfield.TextInputEditText
                android:id="@+id/passwordEditText"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:paddingRight="40dp"
                android:inputType="textPassword" />

It looks like this.

Screenshot

Related