旋转图像,并且显示旋转角 [英] Rotating an image, and displaying angle of rotation
本文介绍了旋转图像,并且显示旋转角的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在做Android的虚拟车速表。 我用的是RotateAnimation()旋转速度表指针。
I am making a virtual speedometer in android. I use the RotateAnimation() to rotate the speedometer needle.
有没有什么办法让针的旋转过程中的角位置?也就是说,如果将针旋转从0到360度,我想在动画的期间,以显示在各点的针角度。 我用下面的code来进行动画。
Is there any way to get the angular position of the needle during the rotation? That is, if the needle is rotating from 0 to 360 degree, I want to display the needles angle at each point during the period of animation. I use the following code to perform the animation.
RotateAnimation rpmNeedleDeflection = new RotateAnimation(-32, 213, (float) 135, needle.getHeight()/2);
rpmNeedleDeflection.setDuration(1500);
rpmNeedleDeflection.setFillAfter(true);
needle.startAnimation(rpmNeedleDeflection);
needle.refreshDrawableState();
任何帮助,请... 先谢谢了。
Any help please... Thanks in advance.
推荐答案
您可以尝试重写applyTransformation
you may try to override applyTransformation
RotateAnimation rpmNeedleDeflection = new RotateAnimation(fromDegrees, toDegrees, ...){
protected void applyTransformation(float interpolatedTime,Transformation t) {
float currentDegree = fromDegrees+(toDegrees-fromDegrees)*interpolatedTime;
super.applyTransformation(interpolatedTime, t);
};
}
这篇关于旋转图像,并且显示旋转角的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文