Use setTint, setTintMode methods from the DrawableCompat class to set tint for drawable programmatically.
Drawable drawable = R.drawable.image; //Your drawable image
drawable = DrawableCompat.wrap(drawable);
DrawableCompat.setTint(drawable, Color.GREEN); // Set whatever color you want
DrawableCompat.setTintMode(drawable, PorterDuff.Mode.SRC_OVER);
And after set the drawable for the editText:
editText.setCompoundDrawablesWithIntrinsicBounds(drawable, null, null, null);
EDIT 1:
Make change in Drawable line as below.
Drawable drawable = getResources().getDrawable(R.drawable.ic_done);
EDIT 2
Use Focus Change Listener of Edit Text.
edit_Text.setOnFocusChangeListener(new OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
if(hasFocus){
Drawable drawable = R.drawable.image; //Your drawable image
drawable = DrawableCompat.wrap(drawable);
DrawableCompat.setTint(drawable, Color.GREEN); // Set whatever color you want
DrawableCompat.setTintMode(drawable, PorterDuff.Mode.SRC_OVER);
editText.setCompoundDrawablesWithIntrinsicBounds(drawable, null, null, null);
}else {
}
}
});