在android中执行动画序列
我需要在图像视图上执行一系列动画。
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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您必须在使用 onAnimationEnd() 方法完成 RotateAnimation 后保存图像。
You must be save your image after completing your RotateAnimation using onAnimationEnd() method.