旋转图像,并显示旋转角度 [英] 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 度,我想在动画期间显示每个点的指针角度.我使用以下代码来执行动画.
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屋!
查看全文