アニメーションクラスを書く
public class Animate extends Animation implements AnimationListener {
public int height,width;
@Override
public void initialize(int width, int height, int parentWidth,
int parentHeight) {
// TODO Auto-generated method stub
super.initialize(width, height, parentWidth, parentHeight);
this.width = width;
this.height = height;
setDuration(500);
setFillAfter(true);
setInterpolator(new LinearInterpolator());
}
Camera camera = new Camera();
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
// TODO Auto-generated method stub
super.applyTransformation(interpolatedTime, t);
Matrix matrix = t.getMatrix();
camera.save();
camera.getMatrix(matrix);
matrix.setTranslate(0, (-height * interpolatedTime));
matrix.preTranslate(0, -height);
camera.restore();
}
レイアウトをアニメーション化するために使用します
View v= new View();
// use whatever view you want and set it up
v.startAnimation(new Animate());