private void updateDrawable(@DrawableRes int iconResourceId, boolean needsTint) { final Drawable icon = ContextCompat.getDrawable(getContext(), iconResourceId); Drawable[] drawables = mCardNumberEditText.getCompoundDrawables(); Drawable original = drawables[0]; if (original == null) { return; } Rect copyBounds = new Rect(); original.copyBounds(copyBounds); int iconPadding = mCardNumberEditText.getCompoundDrawablePadding(); if (!mHasAdjustedDrawable) { copyBounds.top = copyBounds.top - getDynamicBufferInPixels(); copyBounds.bottom = copyBounds.bottom - getDynamicBufferInPixels(); mHasAdjustedDrawable = true; } icon.setBounds(copyBounds); Drawable compatIcon = DrawableCompat.wrap(icon); if (needsTint) { DrawableCompat.setTint(compatIcon.mutate(), mTintColorInt); } mCardNumberEditText.setCompoundDrawablePadding(iconPadding); mCardNumberEditText.setCompoundDrawables(compatIcon, null, null, null); }