在android中执行动画序列

发布于 2024-12-08 18:00:41 字数 1500 浏览 3 评论 0原文

我需要在图像视图上执行一系列动画。

1) 旋转

2) 应用旋转后的平移。

但是每当我在应用旋转后平移图像视图时。我的图像视图将重置为原始位置,然后它会平移。 我无法使用 AnimationSet,因为我正在按以下方式应用动画。

我正在 ACTION_MOVE 上旋转图像视图 和 正在翻译 ACTION_UP。

请帮助我

代码片段:

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[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;

            }
        } 

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

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[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;

            }
        } 

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

千仐 2024-12-15 18:00:41

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

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文