RotationAnimation incosistency between emulator and device
<p>I am trying to rotate a bitmap using the code below.</p>

<p>The code works fine on emulator (although the infinite rotation has a small lag but that's another story) but when tested on the actual device the rotation is wrong (wrong pivot I think).</p>

<p>I appreciate any help.</p>

<p>G</p>

<p>public class CircleAnimation extends View {</p>

<pre><code>Bitmap bitmap;
Paint paint;
RotateAnimation rotate;
AlphaAnimation blend;
ScaleAnimation scale;
AnimationSet spriteAnimation;

float centerX;
float centerY;
float offsetX;
float offsetY;

public CircleAnimation(Context context) {
      super(context);
      // TODO Auto-generated constructor stub

      bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.tile);
        offsetX = bitmap.getWidth() / 2;
        offsetY = bitmap.getHeight() / 2;

        paint = new Paint();
        paint.setAntiAlias(true);
        paint.setFilterBitmap(true);
}

@Override
protected void onDraw(Canvas canvas){
    //Bitmap myBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.tile);
    //canvas.drawBitmap(myBitmap, 0, 0, null);
    super.onDraw(canvas);

    if (spriteAnimation == null) {
        centerX = canvas.getWidth() / 2;
        centerY = canvas.getHeight() / 2;
        createAnimation(canvas);
    }
    canvas.drawBitmap(bitmap, centerX - offsetX, centerY - offsetY, paint);
}

private void createAnimation(final Canvas canvas) {

    rotate = new RotateAnimation(0, 360, centerX, centerY);
    rotate.setRepeatCount(Animation.INFINITE);
    rotate.setInterpolator(new LinearInterpolator());
    rotate.setStartOffset(0);

    spriteAnimation = new AnimationSet(true);
    spriteAnimation.addAnimation(rotate);
    spriteAnimation.setDuration(1000);

    startAnimation(spriteAnimation);

}
</code></pre>

<p>}</p>
