|
1 | 1 | package com.getbase.floatingactionbutton;
|
2 | 2 |
|
| 3 | +import android.animation.Animator; |
| 4 | +import android.animation.AnimatorListenerAdapter; |
3 | 5 | import android.animation.AnimatorSet;
|
4 | 6 | import android.animation.ObjectAnimator;
|
5 | 7 | import android.content.Context;
|
@@ -469,13 +471,30 @@ public void setAnimationsTarget(View view) {
|
469 | 471 |
|
470 | 472 | // Now that the animations have targets, set them to be played
|
471 | 473 | if (!animationsSetToPlay) {
|
| 474 | + addLayerTypeListener(mExpandDir, view); |
| 475 | + addLayerTypeListener(mCollapseDir, view); |
| 476 | + |
472 | 477 | mCollapseAnimation.play(mCollapseAlpha);
|
473 | 478 | mCollapseAnimation.play(mCollapseDir);
|
474 | 479 | mExpandAnimation.play(mExpandAlpha);
|
475 | 480 | mExpandAnimation.play(mExpandDir);
|
476 | 481 | animationsSetToPlay = true;
|
477 | 482 | }
|
478 | 483 | }
|
| 484 | + |
| 485 | + private void addLayerTypeListener(Animator animator, final View view) { |
| 486 | + animator.addListener(new AnimatorListenerAdapter() { |
| 487 | + @Override |
| 488 | + public void onAnimationEnd(Animator animation) { |
| 489 | + view.setLayerType(LAYER_TYPE_NONE, null); |
| 490 | + } |
| 491 | + |
| 492 | + @Override |
| 493 | + public void onAnimationStart(Animator animation) { |
| 494 | + view.setLayerType(LAYER_TYPE_HARDWARE, null); |
| 495 | + } |
| 496 | + }); |
| 497 | + } |
479 | 498 | }
|
480 | 499 |
|
481 | 500 | @Override
|
|
0 commit comments