我想将连续动画(比如 ScaleAnimation)应用于显示资源图像的 ImageView。动画由按钮触发。例如,我想在每次单击按钮时逐步放大图像。
我在动画上设置了 fillAfter="true"。但是,所有的动画都是从 ImageView 的原始状态开始的。看起来好像 ImageView 重置了它的状态并且动画总是一样的,而不是从上一个动画的最终状态开始。
我究竟做错了什么?
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button button = (Button)findViewById(R.id.Button01);
button.setOnClickListener(new OnClickListener() {
public void onClick(View arg0) {
animate();
}});
}
private void animate() {
ImageView imageView = (ImageView) findViewById(R.id.ImageView01);
ScaleAnimation scale = new ScaleAnimation((float)1.0, (float)1.5, (float)1.0, (float)1.5);
scale.setFillAfter(true);
scale.setDuration(500);
imageView.startAnimation(scale);
}