I want to use TextInputLayout with my new application. I have such a layout
*** <android.support.design.widget.TextInputLayout android:id="@+id/input_layout_email" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginBottom="8dp" android:textColorHint="@color/text_color" app:hintTextAppearance="@style/HintTextAppearance.TextInputLayout" app:errorTextAppearance="@style/ErrorTextAppearance.TextInputLayout"> <EditText android:id="@+id/input_email" android:layout_width="match_parent" android:layout_height="wrap_content" android:inputType="textEmailAddress" android:hint="@string/hint_email" android:background="@drawable/edit_text_border_radius" android:padding="10dp" android:drawableLeft="@drawable/ic_acc"/> </android.support.design.widget.TextInputLayout> ***
In my activity I have confirmation, as shown below:
private boolean validatePassword() { if (inputPassword.getText().toString().trim().isEmpty()) { inputLayoutPassword.setError(getString(R.string.err_msg_password)); requestFocus(inputPassword); return false; } else { inputLayoutPassword.setError(null);// it removes @drawable/edit_text_border_radius style from EditText inputLayoutPassword.setErrorEnabled(false); } return true; }
Does not work. but as you noticed, I declared the @ drawable / edit_text_border_radius resource for EditText. And if for the first time I do not fill out the password field, it will change the background color to red. Since this is the default color for the TextInputLayout error range. But then, if I fill in the same field with some values, then the red error range disappears, but the EditText element forgets that the background resource (@ drawable / edit_text_border_radius) is set in front of it.
source share