What you can do is set drawableLeft as it was in your xml and add addTextChangedListener to your EditText. When typing, this listener will be warned, and you can check the listener if the text is greater than 0. If so, just set the drawableLeft , assigned in xml programmatically, to null .
@Override public void afterTextChanged(Editable s) { if(s.toString().length() > 0) { editText.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0); } else {
source share