AnimaitonManager.java
1.84 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
61
package com.glsx.aicar.manager;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.OvershootInterpolator;
import android.view.animation.ScaleAnimation;
/**
* 缩放动画管理类
*/
public class AnimaitonManager {
private static AnimaitonManager instance;
/* public synchronized static AnimaitonManager getInstance() {
if (instance == null) {
instance = new AnimaitonManager();
}
return instance;
}*/
//单例安全及性能优化
private static class Holder{
private static final AnimaitonManager INSTANCE = new AnimaitonManager();
}
public static final AnimaitonManager getInstance(){
return Holder.INSTANCE;
}
public Animation getScaleOutAnimation() {
ScaleAnimation scaleAnimation = new ScaleAnimation(0, 1, 0, 1,
Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF,
0.5f);
//动画持续时长
scaleAnimation.setDuration(1000);
//动画结束之后是否保持动画的最终状态
scaleAnimation.setFillAfter(true);
//动画插值器。是实现动画不规则运动的一种方式
scaleAnimation.setInterpolator(new OvershootInterpolator());
return scaleAnimation;
}
public Animation getAlphaOutAnimation() {
AlphaAnimation alphaAnimation = new AlphaAnimation(0.1f,1.0f);
alphaAnimation.setDuration(500);
alphaAnimation.setFillAfter(true);
alphaAnimation.setInterpolator(new OvershootInterpolator());
return alphaAnimation;
}
public Animation getScaleOutAnimation(long delay) {
ScaleAnimation scaleAnimation = new ScaleAnimation(0, 1, 0, 1,
Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF,
0.5f);
scaleAnimation.setDuration(1000);
scaleAnimation.setStartOffset(delay);
scaleAnimation.setFillAfter(true);
//scaleAnimation.setInterpolator(new OvershootInterpolator());
return scaleAnimation;
}
}