如何将旋转动画与平移动画结合使用?
我在示例应用程序中使用手势侦听器,并在其中的 onFling() 方法中我想执行旋转和平移动画。
individual 都工作正常,但是当我将其集成到 Animation Set 中时,它无法正常工作。
请建议我如何处理这个问题。
以下是我的 onFling 方法的代码:
onFling(MotionEvent e1, MotionEvent e2, floatvelocityX, 浮动速度Y) {
translateAnimation = new TranslateAnimation(0,x2,0,y2); // x2=e2.getX() and y2=e2.getY()
translateAnimation.setDuration(3000);
rotateAnimation = new RotateAnimation(0, 90, RotateAnimation.RELATIVE_TO_SELF, RotateAnimation.RELATIVE_TO_SELF);
rotateAnimation.setStartOffset(1400);
rotateAnimation.setInterpolator(new AccelerateInterpolator());
animationSet.addAnimation(translateAnimation);
animationSet.addAnimation(rotateAnimation);
animationSet.setAnimationListener(this);
animationSet.setDuration(3000);
lastView.startAnimation(animationSet);
}
非常感谢
I am using gesture listener in my sample app, and in it;s onFling() method I want to perform both Rotate and Translate Animation.
individual both work fine, but when I Integrate it in Animation Set , it's not work in proper .
Please suggest me how can I Handle this.
Following is code of my onFling method :
onFling(MotionEvent e1, MotionEvent e2, float velocityX,
float velocityY) {
translateAnimation = new TranslateAnimation(0,x2,0,y2); // x2=e2.getX() and y2=e2.getY()
translateAnimation.setDuration(3000);
rotateAnimation = new RotateAnimation(0, 90, RotateAnimation.RELATIVE_TO_SELF, RotateAnimation.RELATIVE_TO_SELF);
rotateAnimation.setStartOffset(1400);
rotateAnimation.setInterpolator(new AccelerateInterpolator());
animationSet.addAnimation(translateAnimation);
animationSet.addAnimation(rotateAnimation);
animationSet.setAnimationListener(this);
animationSet.setDuration(3000);
lastView.startAnimation(animationSet);
}
Thanking you lot
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)