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

 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/

10-09 13:03