gpt4 book ai didi

android - ontouch逐帧动画

转载 作者:行者123 更新时间:2023-11-29 13:58:24 25 4
gpt4 key购买 nike

如何在用于逐帧动画的 ImageView 上实现触摸...我正在使用它如下

 final AnimationDrawable newtonAnimation = (AnimationDrawable) animation.getBackground();

AnimationStart(newtonAnimation);

animation.setOnTouchListener(l);


public void AnimationStart(final AnimationDrawable newanimation){
Thread timer=new Thread(){
@Override
public void run(){
try{
sleep(40);
}catch(Exception e){}
finally{
Newton_LawsActivity.this.runOnUiThread(new Runnable() {
public void run(){
newanimation.start();
}});
}
}
};
timer.start();

} 这是我获得 ontouch 事件的地方.......

public boolean onTouch(View v, MotionEvent event) {
// TODO Auto-generated method stub
Log.w("debug","nullis event"+event+"OR"+gestureDetector.onTouchEvent(event));

return gestureDetector.onTouchEvent(event);
}

最佳答案

像下面这样设置ontouch lintener

             animation.setOnTouchListener(new OnTouchListener()
{
@Override
public boolean onTouch(View v, MotionEvent event)
{
newtonAnimation.stop();
Toast.makeText(FrameAnimationActivity.this, "animation stoped", Toast.LENGTH_LONG).show();
return false;
}
});

关于android - ontouch逐帧动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10894200/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com