Skip to content

Commit

Permalink
Programmatically set Material Design icons
Browse files Browse the repository at this point in the history
  • Loading branch information
rengwuxian committed Jan 11, 2015
1 parent 3a3e0a8 commit c5defd1
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit c5defd1

Please sign in to comment.