Skip to content
This repository was archived by the owner on Oct 23, 2020. It is now read-only.
Open
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 @@ -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;
Expand Down Expand Up @@ -1073,15 +1073,15 @@ public void toggle(boolean animate) {
}
}

public void setLabelText(String text) {
public void setLabelText(CharSequence text) {
mLabelText = text;
TextView labelView = getLabelView();
if (labelView != null) {
labelView.setText(text);
}
}

public String getLabelText() {
public CharSequence getLabelText() {
return mLabelText;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down