setCompoundDrawablesRelative(null, null, null, null);
}
private void showClearDrawable() {
- setCompoundDrawablesRelativeWithIntrinsicBounds(0, 0, R.drawable.ic_clear_black_24dp, 0);
+ setCompoundDrawablesRelativeWithIntrinsicBounds(0, 0, R.drawable.ic_clear_accent_24dp, 0);
}
@Override
protected void onTextChanged(CharSequence text, int start, int lengthBefore, int lengthAfter) {
final boolean hasText = text.length() > 0;
- if (hadText && !hasText) hideClearDrawable();
- if (!hadText && hasText) showClearDrawable();
+ if (hasFocus()) {
+ if (hadText && !hasText) hideClearDrawable();
+ if (!hadText && hasText) showClearDrawable();
+ }
hadText = hasText;