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 3482019..1a2619a 100755 --- a/library/src/main/java/com/github/clans/fab/FloatingActionButton.java +++ b/library/src/main/java/com/github/clans/fab/FloatingActionButton.java @@ -38,6 +38,9 @@ import android.widget.ImageButton; import android.widget.TextView; +import java.util.ArrayList; +import java.util.List; + public class FloatingActionButton extends ImageButton { public static final int SIZE_NORMAL = 0; @@ -69,6 +72,8 @@ public class FloatingActionButton extends ImageButton { private boolean mUsingElevation; private boolean mUsingElevationCompat; + private List mUsedTags; + // Progress private boolean mProgressBarEnabled; private int mProgressWidth = Util.dpToPx(getContext(), 6f); @@ -118,6 +123,8 @@ public FloatingActionButton(Context context, AttributeSet attrs, int defStyleAtt } private void init(Context context, AttributeSet attrs, int defStyleAttr) { + mUsedTags = new ArrayList<>(); + TypedArray attr = context.obtainStyledAttributes(attrs, R.styleable.FloatingActionButton, defStyleAttr, 0); mColorNormal = attr.getColor(R.styleable.FloatingActionButton_fab_colorNormal, 0xFFDA4336); mColorPressed = attr.getColor(R.styleable.FloatingActionButton_fab_colorPressed, 0xFFE75043); @@ -1311,4 +1318,23 @@ public void setLabelTextColor(int color) { public void setLabelTextColor(ColorStateList colors) { getLabelView().setTextColor(colors); } + + @Override + public void setTag(int key, Object tag) { + super.setTag(key, tag); + + if (key == R.id.fab_label) return; + + if (!mUsedTags.contains(key)) { + mUsedTags.add(key); + } + Label label = getLabelView(); + if (label != null) { + label.setTag(key, tag); + } + } + + List getUsedTags() { + return mUsedTags; + } } 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 f107b76..b5b3297 100755 --- a/library/src/main/java/com/github/clans/fab/FloatingActionMenu.java +++ b/library/src/main/java/com/github/clans/fab/FloatingActionMenu.java @@ -473,6 +473,9 @@ private void addLabel(FloatingActionButton fab) { label.setFab(fab); label.setShowAnimation(AnimationUtils.loadAnimation(getContext(), mLabelsShowAnimation)); label.setHideAnimation(AnimationUtils.loadAnimation(getContext(), mLabelsHideAnimation)); + for (Integer key : fab.getUsedTags()) { + label.setTag(key, fab.getTag(key)); + } if (mLabelsStyle > 0) { label.setTextAppearance(getContext(), mLabelsStyle); @@ -977,7 +980,7 @@ public void addMenuButton(FloatingActionButton fab, int index) { public void removeAllMenuButtons() { close(true); - + List viewsToRemove = new ArrayList<>(); for (int i = 0; i < getChildCount(); i++) { View v = getChildAt(i);