Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set icon padding programmatically #335

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -1520,4 +1543,4 @@ private int checkLength(CharSequence text) {
if (lengthChecker==null) return text.length();
return lengthChecker.getLength(text);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -1525,4 +1548,4 @@ private int checkLength(CharSequence text) {
if (lengthChecker==null) return text.length();
return lengthChecker.getLength(text);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -1517,4 +1540,4 @@ private int checkLength(CharSequence text) {
if (lengthChecker==null) return text.length();
return lengthChecker.getLength(text);
}
}
}