我在android中制作虚拟车速表.
我使用RotateAnimation()来旋转速度表针.
有没有办法在旋转过程中获得针的角度位置?也就是说,如果针从0度旋转到360度,我想在动画期间的每个点显示针角.
我使用以下代码来执行动画.
RotateAnimation rpmNeedleDeflection = new RotateAnimation(-32, 213, (float) 135, needle.getHeight()/2);
rpmNeedleDeflection.setDuration(1500);
rpmNeedleDeflection.setFillAfter(true);
needle.startAnimation(rpmNeedleDeflection);
needle.refreshDrawableState();
请帮忙…
提前致谢.
解决方法:
您可以尝试覆盖applyTransformation
RotateAnimation rpmNeedleDeflection = new RotateAnimation(fromDegrees, toDegrees, ...){
protected void applyTransformation(float interpolatedTime,Transformation t) {
float currentDegree = fromDegrees+(toDegrees-fromDegrees)*interpolatedTime;
super.applyTransformation(interpolatedTime, t);
};
}