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

Font icons colors are edited programmatically #17

Merged
merged 6 commits into from
Apr 13, 2015
Merged
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 @@ -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