在android中执行动画序列

时间:2011-10-10 07:08:09

标签: android-animation

我需要在imageview上执行一系列动画。

1)轮换

2)应用轮换后的翻译。

但每当我在应用旋转后翻译我的图像视图。我的图像视图被重置为原始位置然后它翻译。 我无法使用AnimationSet,因为我正在以下列方式应用动画。

我正在ACTION_MOVE上旋转imageview 和 翻译ACTION_UP。

Plz帮帮我

CODE代码段:

public boolean onTouch(View v,MotionEvent事件)  {

                                             if(event.getAction()==MotionEvent.ACTION_MOVE)
            {
                finX=event.getX();
                finY=event.getY();
                moved=true;
                metrics=    player.determineAngle(finX, finY);
                //required angle is metrics[0]
                Rotate3dAnimation rotate=new Rotate3dAnimation(metrics[0], metrics[0], weapon.getBackground().getMinimumWidth()/2, weapon.getBackground().getMinimumHeight()/2, 0f, false);
                rotate.setDuration(50);
                weapon.startAnimation(rotate);
                rotate.setFillAfter(true);
                                }
            else if(event.getAction()==MotionEvent.ACTION_UP){


                                            rebound=new TranslateAnimation(0, 5, 0, 5);

                    reboundI=new OvershootInterpolator(10f);
                    rebound.setInterpolator(reboundI);
                    rebound.setDuration(500);
                    weapon.startAnimation(rebound);




                }

        }
                return true;

            }
        } 

我可以通过旋转完成转换,但没有方法用该转换初始化另一个动画。或者是否有其他方法可以成功实现这两个动画。 提前致谢

1 个答案:

答案 0 :(得分:0)

使用onAnimationEnd()方法完成RotateAnimation后,必须保存图像。