/** * Set Icon Position * Use the global variables (FancyButton.POSITION_LEFT, FancyButton.POSITION_RIGHT, FancyButton.POSITION_TOP, FancyButton.POSITION_BOTTOM) * * @param position : Position */ public void setIconPosition(int position) { if (position > 0 && position < 5) mIconPosition = position; else mIconPosition = POSITION_LEFT; initializeFancyButton(); }
/** * Set a font icon to the button (eg FFontAwesome or Entypo...) * * @param icon : Icon value eg : \uf082 */ public void setIconResource(String icon) { this.mFontIcon = icon; if (mFontIconView == null) { mIconView = null; initializeFancyButton(); } else mFontIconView.setText(icon); }
/** * Set Disabled state color of the button text * * @param color : use Color.parse('#code') */ public void setDisableTextColor(int color) { this.mDisabledTextColor = color; if (mTextView == null) initializeFancyButton(); else if (!mEnabled) mTextView.setTextColor(color); }
/** * Set the color of text * * @param color : Color * use Color.parse('#code') */ public void setTextColor(int color) { this.mDefaultTextColor = color; if (mTextView == null) initializeFancyButton(); else mTextView.setTextColor(color); }
/** * Set a drawable to the button * * @param drawable : Drawable resource */ public void setIconResource(Drawable drawable) { this.mIconResource = drawable; if (mIconView == null || mFontIconView != null) { mFontIconView = null; initializeFancyButton(); } else mIconView.setImageDrawable(mIconResource); }
/** * Set Text of the button * * @param text : Text */ public void setText(String text) { text = mTextAllCaps ? text.toUpperCase() : text; this.mText = text; if (mTextView == null) initializeFancyButton(); else mTextView.setText(text); }
/** * Set an icon from resources to the button * * @param drawable : Int resource */ public void setIconResource(int drawable) { this.mIconResource = mContext.getResources().getDrawable(drawable); if (mIconView == null || mFontIconView != null) { mFontIconView = null; initializeFancyButton(); } else mIconView.setImageDrawable(mIconResource); }
/** * Override setEnabled and rebuild the fancybutton view * To redraw the button according to the state : enabled or disabled * * @param value */ @Override public void setEnabled(boolean value) { super.setEnabled(value); this.mEnabled = value; initializeFancyButton(); }
/** * Set custom font for button Text * * @param fontName : Font Name * Place your text fonts in assets */ public void setCustomTextFont(String fontName) { mTextTypeFace = Utils.findFont(mContext, fontName, mDefaultTextFont); if (mTextView == null) initializeFancyButton(); else mTextView.setTypeface(mTextTypeFace, textStyle); }
/** * Set Custom font for button icon * * @param fontName : Font Name * Place your icon fonts in assets */ public void setCustomIconFont(String fontName) { mIconTypeFace = Utils.findFont(mContext, fontName, mDefaultIconFont); if (mFontIconView == null) initializeFancyButton(); else mFontIconView.setTypeface(mIconTypeFace); }
/** * Default constructor called from Layouts * * @param context : Context * @param attrs : Attributes Array */ public FancyButton(Context context, AttributeSet attrs) { super(context, attrs); this.mContext = context; TypedArray attrsArray = context.obtainStyledAttributes(attrs, R.styleable.FancyButtonsAttrs, 0, 0); initAttributesArray(attrsArray); attrsArray.recycle(); initializeFancyButton(); }
/** * Default constructor * * @param context : Context */ public FancyButton(Context context) { super(context); this.mContext = context; mTextTypeFace = Utils.findFont(mContext, mDefaultTextFont, null); mIconTypeFace = Utils.findFont(mContext, mDefaultIconFont, null); initializeFancyButton(); }
/** * Set custom font for button Text * * @param fontId : Font id * Place your text fonts in font resources. * Eg. res/font/roboto.ttf or res/font/roboto.xml */ public void setCustomTextFont(@FontRes int fontId) { mTextTypeFace = ResourcesCompat.getFont(getContext(), fontId); if (mTextView == null) initializeFancyButton(); else mTextView.setTypeface(mTextTypeFace, textStyle); }