diff --git a/library/src/main/java/com/rengwuxian/materialedittext/MaterialAutoCompleteTextView.java b/library/src/main/java/com/rengwuxian/materialedittext/MaterialAutoCompleteTextView.java index 484ab1a4..b89e0a28 100644 --- a/library/src/main/java/com/rengwuxian/materialedittext/MaterialAutoCompleteTextView.java +++ b/library/src/main/java/com/rengwuxian/materialedittext/MaterialAutoCompleteTextView.java @@ -404,6 +404,26 @@ private Typeface getCustomTypeface(@NonNull String fontPath) { return Typeface.createFromAsset(getContext().getAssets(), fontPath); } + public void setIconLeft(@DrawableRes int res) { + iconLeftBitmaps = generateIconBitmaps(res); + initPadding(); + } + + public void setIconLeft(Bitmap bitmap) { + iconLeftBitmaps = generateIconBitmaps(bitmap); + initPadding(); + } + + public void setIconRight(@DrawableRes int res) { + iconRightBitmaps = generateIconBitmaps(res); + initPadding(); + } + + public void setIconRight(Bitmap bitmap) { + iconRightBitmaps = generateIconBitmaps(bitmap); + initPadding(); + } + private Bitmap[] generateIconBitmaps(@DrawableRes int origin) { if (origin == -1) { return null; diff --git a/library/src/main/java/com/rengwuxian/materialedittext/MaterialEditText.java b/library/src/main/java/com/rengwuxian/materialedittext/MaterialEditText.java index 9ac43305..cab26c3d 100644 --- a/library/src/main/java/com/rengwuxian/materialedittext/MaterialEditText.java +++ b/library/src/main/java/com/rengwuxian/materialedittext/MaterialEditText.java @@ -404,6 +404,26 @@ private Typeface getCustomTypeface(@NonNull String fontPath) { return Typeface.createFromAsset(getContext().getAssets(), fontPath); } + public void setIconLeft(@DrawableRes int res) { + iconLeftBitmaps = generateIconBitmaps(res); + initPadding(); + } + + public void setIconLeft(Bitmap bitmap) { + iconLeftBitmaps = generateIconBitmaps(bitmap); + initPadding(); + } + + public void setIconRight(@DrawableRes int res) { + iconRightBitmaps = generateIconBitmaps(res); + initPadding(); + } + + public void setIconRight(Bitmap bitmap) { + iconRightBitmaps = generateIconBitmaps(bitmap); + initPadding(); + } + private Bitmap[] generateIconBitmaps(@DrawableRes int origin) { if (origin == -1) { return null; diff --git a/library/src/main/java/com/rengwuxian/materialedittext/MaterialMultiAutoCompleteTextView.java b/library/src/main/java/com/rengwuxian/materialedittext/MaterialMultiAutoCompleteTextView.java index 39631d24..4e5ed356 100644 --- a/library/src/main/java/com/rengwuxian/materialedittext/MaterialMultiAutoCompleteTextView.java +++ b/library/src/main/java/com/rengwuxian/materialedittext/MaterialMultiAutoCompleteTextView.java @@ -401,6 +401,26 @@ private Typeface getCustomTypeface(@NonNull String fontPath) { return Typeface.createFromAsset(getContext().getAssets(), fontPath); } + public void setIconLeft(@DrawableRes int res) { + iconLeftBitmaps = generateIconBitmaps(res); + initPadding(); + } + + public void setIconLeft(Bitmap bitmap) { + iconLeftBitmaps = generateIconBitmaps(bitmap); + initPadding(); + } + + public void setIconRight(@DrawableRes int res) { + iconRightBitmaps = generateIconBitmaps(res); + initPadding(); + } + + public void setIconRight(Bitmap bitmap) { + iconRightBitmaps = generateIconBitmaps(bitmap); + initPadding(); + } + private Bitmap[] generateIconBitmaps(@DrawableRes int origin) { if (origin == -1) { return null;