I am using a password toggle to show and hide the password. And I do not want to use the custom drawable. But, when this edit text generate error it overrides the toggle password icon and unable to add padding or margin to that icon. If there is any solution to this, it will be a pleasure. This is the code I am using:
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:textColorHint="@color/white"
app:passwordToggleEnabled="true"
app:passwordToggleTint="@color/white">
<EditText
android:id="@+id/et_password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:backgroundTint="@color/white"
android:hint="@string/password"
android:imeOptions="actionDone"
android:inputType="textPassword"
android:maxLength="40"
android:maxLines="1"
android:textColor="@color/white"
android:textColorHint="@color/app_green_color" />
</com.google.android.material.textfield.TextInputLayout>
Use the TextInputEditText
instead of the EditText
.
<com.google.android.material.textfield.TextInputLayout
app:endIconMode="password_toggle"
app:endIconTint="@color/white"
...>
<com.google.android.material.textfield.TextInputEditText
android:inputType="textPassword"
../>
</com.google.android.material.textfield.TextInputLayout>
Also (but it is not related to the issue) the attributes app:passwordToggleEnabled="true"
and app:passwordToggleTint="@color/white"
are now deprecated. Use app:endIconMode
and app:endIconTint
.