ViewAnimUtil.java
2.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package com.cnlive.strike.xiaojiaspeaker;
import android.animation.Animator;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.os.Build;
import android.os.Handler;
import android.view.View;
import android.view.ViewAnimationUtils;
import android.view.animation.Animation;
import android.view.animation.BounceInterpolator;
import android.view.animation.DecelerateInterpolator;
import android.view.animation.LinearInterpolator;
import android.view.animation.RotateAnimation;
import com.daimajia.androidanimations.library.Techniques;
import com.daimajia.androidanimations.library.YoYo;
/**
* 圆形按钮点击特效
*
* @author ShinnyYang
*/
public class ViewAnimUtil {
//设置控件显示放大动画
public static void setViewShowZoomIn(View view, float zoomIn) {
try {
//放大动画
AnimatorSet animatorSetsuofang = new AnimatorSet();//组合动画
ObjectAnimator scaleX = ObjectAnimator.ofFloat(view, "scaleX", 1, zoomIn);
ObjectAnimator scaleY = ObjectAnimator.ofFloat(view, "scaleY", 1, zoomIn);
//延时播放缩小动画
ObjectAnimator scaleXBack = ObjectAnimator.ofFloat(view, "scaleX", zoomIn, 1);
scaleXBack.setStartDelay(500);
ObjectAnimator scaleYBack = ObjectAnimator.ofFloat(view, "scaleY", zoomIn, 1);
scaleYBack.setStartDelay(500);
// ObjectAnimator rotateBack1 = ObjectAnimator.ofFloat(view, "rotation", 30f, 0f).setDuration(100);
//// //顺时针旋转45°
// ObjectAnimator rotate = ObjectAnimator.ofFloat(view, "rotation", 30f, 30f).setDuration(100);
// rotate.setStartDelay(300);
//// //逆时针旋转45°
// ObjectAnimator rotateBack = ObjectAnimator.ofFloat(view, "rotation", 30f, 0f).setDuration(100);
// rotateBack.setStartDelay(300);
//旋转
ObjectAnimator rotateBack = ObjectAnimator.ofFloat(view, "rotation", 0, 30, -30, 16, -16, 13, -13, 0);
rotateBack.setStartDelay(100);
animatorSetsuofang.play(scaleX).with(scaleY).with(scaleXBack).with(scaleYBack).with(rotateBack);//两个动画同时开始
animatorSetsuofang.setInterpolator(new DecelerateInterpolator());
animatorSetsuofang.setDuration(500);
animatorSetsuofang.start();
// YoYo.with(Techniques.Swing)
// .duration(1000)
// .repeat(0)
// .playOn(view);
} catch (Exception e) {
}
}
}