我在做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);
};
}