Change theme
Help
Press space for more information.
Show links for this issue (Shortcut: i, l)
Copy issue ID
Previous Issue (Shortcut: k)
Next Issue (Shortcut: j)
Sign in to use full features.
Vote: I am impacted
Notification menu
Refresh (Shortcut: Shift+r)
Go home (Shortcut: u)
Pending code changes (auto-populated)
View issue level access limits(Press Alt + Right arrow for more information)
Attachment actions
Unintended behavior
View staffing
Description
Version used: 23.2.1
Theme used: Theme.AppCompat.Light.DarkActionBar
Devices/Android versions reproduced on: API 16
When clearing error text in TextInputLayout, EditText background color turns black instead of return to its default color.
To reproduce:
final EditText editText = (EditText)findViewById(...);
editText.addTextChangedListener(new TextWatcher()
{
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after)
{ }
@Override
public void onTextChanged(CharSequence s, int start, int before, int count)
{ }
@Override
public void afterTextChanged(Editable s)
{
TextInputLayout textInputLayout = (TextInputLayout)editText .getParent();
if(s.length() == 0)
textInputLayout.setError("Invalid text input!");
else
textInputLayout.setError(null);
}
});
The bug lies in:
TextInputLayout.updateEditTextBackground() private method where you clear EditText's background color filter instead of returning to its default one.
To fix this:
You need to remember the ColorFilter that was set on EditText background before setting error text (thus before setting red color filter).