Created
June 26, 2019 21:49
-
-
Save akndmr/3293f2419b8c8959e887816af1c3dcce to your computer and use it in GitHub Desktop.
Scale left/start, right/end, top, bottom drawables of EditText
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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