From 74503b4aa34a43ad6f0b31b80c1a7eb381476a8f Mon Sep 17 00:00:00 2001 From: Chris Date: Mon, 26 Jun 2017 22:14:10 +0800 Subject: [PATCH 1/3] Add setIconPadding methods to MaterialAutoCompleteTextView Add two methods, setIconPadding(@DimenRes int) and setIconPadding(float) to allow the icon padding to be set programmatically. --- .../MaterialAutoCompleteTextView.java | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/library/src/main/java/com/rengwuxian/materialedittext/MaterialAutoCompleteTextView.java b/library/src/main/java/com/rengwuxian/materialedittext/MaterialAutoCompleteTextView.java index 89bbf29b..41c196d0 100644 --- a/library/src/main/java/com/rengwuxian/materialedittext/MaterialAutoCompleteTextView.java +++ b/library/src/main/java/com/rengwuxian/materialedittext/MaterialAutoCompleteTextView.java @@ -518,6 +518,29 @@ public void setIconRight(Bitmap bitmap) { initPadding(); } + /** + * Sets the icon padding to a dimension resource. + * @param @DimenRes int id The dimension resource id containing the + * padding size. + */ + public void setIconPadding(@DimenRes int id) { + iconPadding = getResources().getDimensionPixelSize(id); + initPadding(); + } + + /** + * Sets the padding for the icon and defaults to 16dp if a negative value is + * provided. + * + * The floating point number will be immediately truncated to an integer. + * @param float padding A floating point number representing the number of + * pixels to pad the icon with. + */ + public void setIconPadding(float padding) { + iconPadding = padding >= 0 ? (int) padding : getPixel(16) ; + initPadding(); + } + public boolean isShowClearButton() { return showClearButton; } @@ -1520,4 +1543,4 @@ private int checkLength(CharSequence text) { if (lengthChecker==null) return text.length(); return lengthChecker.getLength(text); } -} \ No newline at end of file +} From d766a5b096e28c005110d70a6b30654615d428af Mon Sep 17 00:00:00 2001 From: Chris Date: Mon, 26 Jun 2017 22:18:52 +0800 Subject: [PATCH 2/3] Add setIconPadding methods to MaterialEditText Add two methods, setIconPadding(@DimenRes int) and setIconPadding(float) to allow the icon padding to be set programmatically. --- .../materialedittext/MaterialEditText.java | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/library/src/main/java/com/rengwuxian/materialedittext/MaterialEditText.java b/library/src/main/java/com/rengwuxian/materialedittext/MaterialEditText.java index 516722e6..6d9a8d8f 100755 --- a/library/src/main/java/com/rengwuxian/materialedittext/MaterialEditText.java +++ b/library/src/main/java/com/rengwuxian/materialedittext/MaterialEditText.java @@ -522,6 +522,29 @@ public void setIconRight(Bitmap bitmap) { initPadding(); } + /** + * Sets the icon padding to a dimension resource. + * @param @DimenRes int id The dimension resource id containing the + * padding size. + */ + public void setIconPadding(@DimenRes int id) { + iconPadding = getResources().getDimensionPixelSize(id); + initPadding(); + } + + /** + * Sets the padding for the icon and defaults to 16dp if a negative value is + * provided. + * + * The floating point number will be immediately truncated to an integer. + * @param float padding A floating point number representing the number of + * pixels to pad the icon with. + */ + public void setIconPadding(float padding) { + iconPadding = padding >= 0 ? (int) padding : getPixel(16) ; + initPadding(); + } + public boolean isShowClearButton() { return showClearButton; } @@ -1525,4 +1548,4 @@ private int checkLength(CharSequence text) { if (lengthChecker==null) return text.length(); return lengthChecker.getLength(text); } -} \ No newline at end of file +} From 82ee97ef671ab2c45ac1a72eeb818a4d23c95cf5 Mon Sep 17 00:00:00 2001 From: Chris Date: Mon, 26 Jun 2017 22:20:09 +0800 Subject: [PATCH 3/3] Add setIconPadding methods to MaterialMultiAutoCompleteTextView Add two methods, setIconPadding(@DimenRes int) and setIconPadding(float) to allow the icon padding to be set programmatically. --- .../MaterialMultiAutoCompleteTextView.java | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/library/src/main/java/com/rengwuxian/materialedittext/MaterialMultiAutoCompleteTextView.java b/library/src/main/java/com/rengwuxian/materialedittext/MaterialMultiAutoCompleteTextView.java index 68c268cd..75c12d4f 100644 --- a/library/src/main/java/com/rengwuxian/materialedittext/MaterialMultiAutoCompleteTextView.java +++ b/library/src/main/java/com/rengwuxian/materialedittext/MaterialMultiAutoCompleteTextView.java @@ -515,6 +515,29 @@ public void setIconRight(Bitmap bitmap) { initPadding(); } + /** + * Sets the icon padding to a dimension resource. + * @param @DimenRes int id The dimension resource id containing the + * padding size. + */ + public void setIconPadding(@DimenRes int id) { + iconPadding = getResources().getDimensionPixelSize(id); + initPadding(); + } + + /** + * Sets the padding for the icon and defaults to 16dp if a negative value is + * provided. + * + * The floating point number will be immediately truncated to an integer. + * @param float padding A floating point number representing the number of + * pixels to pad the icon with. + */ + public void setIconPadding(float padding) { + iconPadding = padding >= 0 ? (int) padding : getPixel(16) ; + initPadding(); + } + public boolean isShowClearButton() { return showClearButton; } @@ -1517,4 +1540,4 @@ private int checkLength(CharSequence text) { if (lengthChecker==null) return text.length(); return lengthChecker.getLength(text); } -} \ No newline at end of file +}