|
43 | 43 | import android.view.ViewGroup.LayoutParams;
|
44 | 44 | import android.view.ViewGroup.MarginLayoutParams;
|
45 | 45 | import androidx.annotation.AnimatorRes;
|
| 46 | +import androidx.annotation.ColorInt; |
46 | 47 | import androidx.annotation.IntDef;
|
47 | 48 | import androidx.annotation.NonNull;
|
48 | 49 | import androidx.annotation.Nullable;
|
@@ -460,6 +461,15 @@ private void saveOriginalTextCsl() {
|
460 | 461 | originalTextCsl = getTextColors();
|
461 | 462 | }
|
462 | 463 |
|
| 464 | + ColorStateList getOriginalTextColor() { |
| 465 | + return originalTextCsl; |
| 466 | + } |
| 467 | + |
| 468 | + @ColorInt |
| 469 | + int getCurrentOriginalTextColor() { |
| 470 | + return originalTextCsl.getColorForState(getDrawableState(), 0); |
| 471 | + } |
| 472 | + |
463 | 473 | /**
|
464 | 474 | * Update the text color without affecting the original, client-set color.
|
465 | 475 | */
|
@@ -1417,7 +1427,9 @@ public AnimatorSet createAnimator() {
|
1417 | 1427 |
|
1418 | 1428 | if (spec.hasPropertyValues("labelOpacity")) {
|
1419 | 1429 | PropertyValuesHolder[] labelOpacityValues = spec.getPropertyValues("labelOpacity");
|
1420 |
| - float startValue = extending ? 0F : 1F; |
| 1430 | + final int originalAlpha = Color.alpha(getCurrentOriginalTextColor()); |
| 1431 | + final int currentAlpha = Color.alpha(getCurrentTextColor()); |
| 1432 | + float startValue = originalAlpha != 0 ? (float) currentAlpha / originalAlpha : 0f; |
1421 | 1433 | float endValue = extending ? 1F : 0F;
|
1422 | 1434 | labelOpacityValues[0].setFloatValues(startValue, endValue);
|
1423 | 1435 | spec.setPropertyValues("labelOpacity", labelOpacityValues);
|
|
0 commit comments