android– 如何在围绕自己的轴旋转路径时移动路径中的对象?

android– 如何在围绕自己的轴旋转路径时移动路径中的对象?,第1张

概述如何在围绕其自身轴旋转路径中的对象时,如下图所示:虽然这是我实际得到的:这是我的代码:AnimationSetas1=newAnimationSet(true);as1.setFillAfter(true);floatdist=0.5f;//Thefollowingistooslowjusttoinspecttheanimationintduration=5000;//5secon

如何在围绕其自身轴旋转路径中的对象时,如下图所示:

虽然这是我实际得到的:

这是我的代码:

AnimationSet as1 = new AnimationSet(true);as1.setFillAfter(true);float dist = 0.5f;// The following is too slow just to inspect the animationint duration = 5000; // 5 seconds// TrIEd the following: relative_TO_SELF and relative_TO_PARENT but no differenceint ttype = Animation.relative_TO_SELF; // Type of translation// Move to X: distance , Y: distanceTranslateAnimation ta1 = new TranslateAnimation( ttype,0,ttype,dist,ttype,0, ttype,dist); ta1.setDuration(duration);// Add Translation to the setas1.addAnimation(ta1);// Rotate around its centerint rtype = Animation.relative_TO_SELF;float rotation = 90;RotateAnimation ra1 = new RotateAnimation(0, rotation,rtype,0.5f , rtype,0.5f );ra1.setDuration(duration);as1.addAnimation(ra1);Object1.startAnimation(as1); // in my app Object1 is an Imagebutton

解决方法:

改变翻译和旋转动画的顺序修复了问题.

总结

以上是内存溢出为你收集整理的android – 如何在围绕自己的轴旋转路径时移动路径中的对象?全部内容,希望文章能够帮你解决android – 如何在围绕自己的轴旋转路径时移动路径中的对象?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://www.outofmemory.cn/web/1106584.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-28
下一篇 2022-05-28

发表评论

登录后才能评论

评论列表(0条)

保存