I have been trying to code an activity method rotating an image to a specific angle. The rotation works but the problem is that the method is called every second or so, but rotates only on the first few times. At a certain point the image being animated just stands still, even though that the animation is being set up and started with different values! which suppose to move the image, as it did the first few times.
private void animateNeedle(final float sfAngle)
{
final View viewNeedle = findViewById(R.id.needle);
final RotateAnimation needleAnimation;
RotateAnimation anim;
anim = new RotateAnimation( 0,
sfAngle,
m_nNeedleWidth / 2,
m_nNeedleHeight);
anim.setDuration(200);
anim.setFillAfter(true);
viewNeedle.setAnimation(anim);
anim.setAnimationListener(new AnimationListener()
{
@Override
public void onAnimationEnd(final Animation animation)
{
viewNeedle.clearAnimation();
}
@Override
public void onAnimationRepeat(final Animation animation)
{
// TODO Auto-generated method stub
}
@Override
public void onAnimationStart(final Animation animation)
{
// TODO Auto-generated method stub
}
});
anim.start();
findViewById(android.R.id.content).postInvalidate();
}
What am I doing wrong? I made sure that the function won't be called twice during of the animation but it doesn't help.
sfAngle
passed is always non-zero? – Sherif elKhatib