旋转图像并显示旋转角度

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);
                };

            }

这篇关于旋转图像并显示旋转角度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:旋转图像并显示旋转角度

基础教程推荐