Customizing the setError icon for EditText

This issue is discussed and resolved here:

EditText setError() with icon but without Popup message

I hope that by extending the answer it would not get auto-converted to a comment.


    Drawable customErrorDrawable = getResources().getDrawable(R.drawable.error_icon);
        customErrorDrawable.setBounds(0, 0, customErrorDrawable.getIntrinsicWidth(), customErrorDrawable.getIntrinsicHeight());


 editText.setError("please enter data",customErrorDrawable);

If you don't want to show any icon at all, use

editText.setError("error", null);

You need to set the bounds on the drawable before using it in setError.

drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
editText.setError("error", drawable);