Skip to content

Commit

Permalink
Merge pull request #17 from kadyEG/changing-icon-color
Browse files Browse the repository at this point in the history
Added new method to define icon color
  • Loading branch information
medyo committed Apr 13, 2015
2 parents 967d7d6 + 2f911e1 commit 5d2eed5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public class FancyButton extends LinearLayout{

// # Text Attributes
private int mDefaultTextColor = Color.WHITE;
private int mDefaultIconColor = Color.WHITE;
private int mTextPosition = 1;
private int mDefaultTextSize = 15;
private int mDefaultTextGravity = 0x11; // Gravity.CENTER
Expand Down Expand Up @@ -193,7 +194,7 @@ private TextView setupFontIconView(){

if(mFontIcon!=null){
TextView fontIconView = new TextView(mContext);
fontIconView.setTextColor(mDefaultTextColor);
fontIconView.setTextColor(mDefaultIconColor);

LayoutParams iconTextViewParams = new LayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.WRAP_CONTENT,1f);
iconTextViewParams.rightMargin = mIconPaddingRight;
Expand Down Expand Up @@ -269,6 +270,8 @@ private void initAttributsArray(TypedArray attrsArray){
mFocusBackgroundColor = attrsArray.getColor(R.styleable.FancyButtonsAttrs_focusColor,mFocusBackgroundColor);

mDefaultTextColor = attrsArray.getColor(R.styleable.FancyButtonsAttrs_textColor,mDefaultTextColor);
// if default color is set then the icon's color is the same (the default for icon's color)
mDefaultIconColor = attrsArray.getColor(R.styleable.FancyButtonsAttrs_iconColor,mDefaultTextColor);
mDefaultTextSize = (int) attrsArray.getDimension(R.styleable.FancyButtonsAttrs_textSize,mDefaultTextSize);
mDefaultTextGravity = attrsArray.getInt(R.styleable.FancyButtonsAttrs_textGravity, mDefaultTextGravity);

Expand Down Expand Up @@ -416,6 +419,16 @@ public void setTextColor(int color){

}

/**
* Setting the icon's color independent of the text color
* @param color : Color
*/
public void setIconColor(int color){
if(mFontIconView != null) {
mFontIconView.setTextColor(color);
}
}

/**
* Set Background color of the button
* @param color : use Color.parse('#code')
Expand Down
1 change: 1 addition & 0 deletions fancybuttons_library/src/main/res/values/attrs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<attr name="text" format="string" />

<attr name="textColor" format="color" />
<attr name="iconColor" format="color" />

<attr name="textFont" format="string" />
<attr name="iconFont" format="string" />
Expand Down

0 comments on commit 5d2eed5

Please sign in to comment.