Add rotation effect for showing fab

This commit is contained in:
seven332 committed 2016-04-01 20:08:07 +08:00
1 parent 250e1256b9
commit 57a9865d99
3 files changed
+16 -4

No files matched your search

@@ -256,14 +256,20 @@ public class FabLayout extends ViewGroup implements View.OnClickListener {
private void setPrimaryFabAnimation(final View child, final boolean expanded, boolean delay) {
float startRotation;
float endRotation;
float startScale;
float endScale;
Interpolator interpolator;
if (expanded) {
startRotation = -45.0f;
endRotation = 0.0f;
startScale = 0.0f;
endScale = 1.0f;
interpolator = AnimationUtils.FAST_SLOW_INTERPOLATOR;
} else {
startRotation = 0.0f;
endRotation = 0.0f;
startScale = 1.0f;
endScale = 0.0f;
interpolator = AnimationUtils.SLOW_FAST_INTERPOLATOR;
@@ -271,9 +277,11 @@ public class FabLayout extends ViewGroup implements View.OnClickListener {
child.setScaleX(startScale);
child.setScaleY(startScale);
child.setRotation(startRotation);
child.animate()
.scaleX(endScale)
.scaleY(endScale)
.rotation(endRotation)
.setStartDelay(delay ? ANIMATE_TIME : 0L)
.setDuration(ANIMATE_TIME)
.setInterpolator(interpolator)