diff --git a/library/src/main/java/com/github/clans/fab/FloatingActionButton.java b/library/src/main/java/com/github/clans/fab/FloatingActionButton.java index e9c98df..58933d3 100755 --- a/library/src/main/java/com/github/clans/fab/FloatingActionButton.java +++ b/library/src/main/java/com/github/clans/fab/FloatingActionButton.java @@ -61,7 +61,7 @@ public class FloatingActionButton extends ImageButton { private int mIconSize = Util.dpToPx(getContext(), 24f); private Animation mShowAnimation; private Animation mHideAnimation; - private String mLabelText; + private CharSequence mLabelText; private OnClickListener mClickListener; private Drawable mBackgroundDrawable; private boolean mUsingElevation; @@ -1073,7 +1073,7 @@ public void toggle(boolean animate) { } } - public void setLabelText(String text) { + public void setLabelText(CharSequence text) { mLabelText = text; TextView labelView = getLabelView(); if (labelView != null) { @@ -1081,7 +1081,7 @@ public void setLabelText(String text) { } } - public String getLabelText() { + public CharSequence getLabelText() { return mLabelText; } diff --git a/library/src/main/java/com/github/clans/fab/FloatingActionMenu.java b/library/src/main/java/com/github/clans/fab/FloatingActionMenu.java index 0b80e4c..2a64eac 100755 --- a/library/src/main/java/com/github/clans/fab/FloatingActionMenu.java +++ b/library/src/main/java/com/github/clans/fab/FloatingActionMenu.java @@ -103,7 +103,7 @@ public class FloatingActionMenu extends ViewGroup { private int mLabelsPosition; private Context mLabelsContext; - private String mMenuLabelText; + private CharSequence mMenuLabelText; private boolean mUsingMenuLabel; public interface OnMenuToggleListener { @@ -474,7 +474,7 @@ public void onClick(View v) { } private void addLabel(FloatingActionButton fab) { - String text = fab.getLabelText(); + CharSequence text = fab.getLabelText(); if (TextUtils.isEmpty(text)) return; @@ -998,11 +998,11 @@ public void removeAllMenuButtons() { } } - public void setMenuButtonLabelText(String text) { + public void setMenuButtonLabelText(CharSequence text) { mMenuButton.setLabelText(text); } - public String getMenuButtonLabelText() { + public CharSequence getMenuButtonLabelText() { return mMenuLabelText; } diff --git a/sample/src/main/java/com/github/clans/fab/sample/MenusFragment.java b/sample/src/main/java/com/github/clans/fab/sample/MenusFragment.java index af0a82c..51081b3 100644 --- a/sample/src/main/java/com/github/clans/fab/sample/MenusFragment.java +++ b/sample/src/main/java/com/github/clans/fab/sample/MenusFragment.java @@ -4,11 +4,18 @@ import android.animation.AnimatorListenerAdapter; import android.animation.AnimatorSet; import android.animation.ObjectAnimator; +import android.graphics.Color; +import android.graphics.Typeface; import android.os.Bundle; import android.os.Handler; import android.support.annotation.Nullable; import android.support.v4.app.Fragment; import android.support.v4.content.ContextCompat; +import android.text.Spannable; +import android.text.SpannableStringBuilder; +import android.text.Spanned; +import android.text.style.ForegroundColorSpan; +import android.text.style.StyleSpan; import android.view.ContextThemeWrapper; import android.view.LayoutInflater; import android.view.View; @@ -98,6 +105,11 @@ public void onClick(View v) { fabEdit = (FloatingActionButton) view.findViewById(R.id.fab_edit); fabEdit.setShowAnimation(AnimationUtils.loadAnimation(getActivity(), R.anim.scale_up)); fabEdit.setHideAnimation(AnimationUtils.loadAnimation(getActivity(), R.anim.scale_down)); + + Spannable spannedText = new SpannableStringBuilder("This is spanned text"); + spannedText.setSpan(new ForegroundColorSpan(Color.RED), 0, 4, Spanned.SPAN_INCLUSIVE_INCLUSIVE); + spannedText.setSpan(new StyleSpan(Typeface.BOLD_ITALIC), 8, 16, Spanned.SPAN_INCLUSIVE_INCLUSIVE); + fab3.setLabelText(spannedText); } @Override