0
我将动画添加到imageview中,我希望保持动画状态,直到时间按钮按下按钮按下移动到前一个状态 这里是我的代码,使用setFillAfter不要让它恢复并设置为false,它不停留在动画状态停止按钮上的动画点击图片
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;
}
});
}