I'm trying to rotate 3 imageViews
with a rotateAnimation
. I calculate the degrees to rotate every 30ms. If the angle changed, I create the rotateAnimation:
rpmAnim=new RotateAnimation((float)Rpmcurrentdegree, (float)Rpmdegree, ivNadel.getWidth()/2, ivNadel.getHeight()/2);
rpmAnim.setFillEnabled(true);
rpmAnim.setFillAfter(true);
...and then I start the animation of the imageView:
ivNadel.startAnimation(rpmAnim);
The rotation works fine, but when the degrees do not change, it jumps back to its starting position. Does anyone know why?
set the setAnimationListener on rpmAnim:
rpmAnim.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationEnd(Animation arg0) {
// here rotate the image
}
@Override
public void onAnimationRepeat(Animation animation) {}
@Override
public void onAnimationStart(Animation animation) {}
});
to rotate the image you can
the overridden onDraw
could look like:
protected void onDraw(Canvas canvas) {
canvas.save()
canvas.rotate(your rotation angle...)
super.onDraw(canvas)
canvas.restore()
}