1
我的ImageView的停止動畫點擊
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
i=(ImageView)findViewById(R.id.imageView1);
d=(Button)findViewById(R.id.button1);
a=new AnimationSet(false);
ScaleAnimation s=new ScaleAnimation(0, 2, 0, 2);
TranslateAnimation t=new TranslateAnimation(0, 100, 0, 0);
a.addAnimation(s);
a.addAnimation(t);
a.setRepeatCount(0);
a.setDuration(500);
a.setFillAfter(false);
a.setInterpolator(new AccelerateDecelerateInterpolator()); i.clearAnimation();
d.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
i.clearAnimation();
}
});
i.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
// TODO Auto-generated method stub
i.startAnimation(a);
System.out.println("OnTouch called>>>>>>>>>>>");
return false;
}
});
}
}
現在的問題是停止動畫和恢復按鈕點擊到那時之前的狀態下的圖像應該保持,因爲它是設置動畫設置爲動畫。 我
可能ü可以刪除行a.reset()。只是添加一個文件 – sush 2012-03-22 10:40:01
試過,已經不行了 – 2012-03-22 11:23:10
clearAnimation()工作正常 – 2012-10-12 21:44:41