Skip to content

Instantly share code, notes, and snippets.

@akndmr
Created June 26, 2019 21:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save akndmr/3293f2419b8c8959e887816af1c3dcce to your computer and use it in GitHub Desktop.
Save akndmr/3293f2419b8c8959e887816af1c3dcce to your computer and use it in GitHub Desktop.
Scale left/start, right/end, top, bottom drawables of EditText
private Drawable getScaledDrawable(int drawableId){
Drawable drawable = getResources().getDrawable(drawableId);
drawable.setBounds(0, 0, (int) (drawable.getIntrinsicWidth() * 0.4),
(int) (drawable.getIntrinsicHeight() * 0.4));
return drawable;
}
/**
* Scale down left drawable
* android:drawableLeft="@drawable/myIcon"
* android:drawableStart="@drawable/myIcon"
*/
myEditText.setCompoundDrawables(getScaledDrawable(), null, null, null);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment