开发者

Performing sequence of animation in android

开发者 https://www.devze.com 2023-04-11 17:18 出处:网络
I need to perform a sequence of animation on an imageview. 1) Rotation 2)Translation after applying rotation.

I need to perform a sequence of animation on an imageview.

1) Rotation

2)Translation after applying rotation.

But whenever I translate my imageview after applying rotation.My imageview is reset to orignal position then it translates . I can't use an AnimationSet as i'm applying an animation in following way.

I'm rotating imageview on ACTION_MOVE and translating on ACTION_UP.

Plz help me out

CODE Snippet:

public boolean onTouch(View v, MotionEvent event) {

                                             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[开发者_如何学JAVA0], 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;

            }
        } 

I can get the transformation done by rotation ,but there is no method to initialize another animation with that transformation.Or is there any other way to achieve these 2 animations successfully. Thanks in advance


You must be save your image after completing your RotateAnimation using onAnimationEnd() method.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号