`
java-mans
  • 浏览: 11415520 次
文章分类
社区版块
存档分类
最新评论

Android 电视退出程序Animation

 
阅读更多

package gongzibai.co.cc;

import android.graphics.Matrix;
import android.view.animation.AccelerateDecelerateInterpolator;
import android.view.animation.Animation;
import android.view.animation.Transformation;

public class TV extends Animation {
private int halfWidth;
private int halfHeight;

@Override
public void initialize(int width, int height, int parentWidth,
int parentHeight) {
// TODO Auto-generated method stub
super.initialize(width, height, parentWidth, parentHeight);
setDuration(800);
setFillAfter(true);
// 保存View的中心点
halfWidth = width / 2;
halfHeight = height / 2;
setInterpolator(new AccelerateDecelerateInterpolator());

}

@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
// TODO Auto-generated method stub
super.applyTransformation(interpolatedTime, t);
final Matrix matrix = t.getMatrix();
if (interpolatedTime < 0.8) {
matrix.preScale(1 + 0.625f * interpolatedTime,
1 - interpolatedTime / 0.8f + 0.01f, halfWidth, halfHeight);
} else {
matrix.preScale(7.5f * (1 - interpolatedTime), 0.01f, halfWidth,
halfHeight);

}
}
}

--------配合定时器 使用:
mLinearLayout.startAnimation(new TVOffAnimation());
new Timer().schedule(new TimerTask() {

@Override
public void run() {
// TODO Auto-generated method stub
android.os.Process.killProcess(android.os.Process.myPid());

}
}, 1000);

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics