Rotate canvas along its center based on user touch - Android
- by Ganapathy
I want to rotate the canvas circularly on its center axis based on user touch.
i want to rotate based on center but its rotating based on top left corner .
so i am able to see only 1/4 for rotation of image.
any idea.. 
Like a old phone dialer .
I have tried like as follows
onDraw(Canvas canvas){
  canvas.save();
  // do my rotation
  canvas.rotate(rotation,0,0);
  canvas.drawBitmap( ((BitmapDrawable)d).getBitmap(),0,0,p );
  canvas.restore();
}
@Override
        public boolean onTouchEvent(MotionEvent e) {
                  float x = e.getX();
              float y = e.getY();
              updateRotation(x,y);
              mPreviousX = x;
              mPreviousY = y;
            invalidate();
        }
  private void updateRotation(float x, float y) {
          double r = Math.atan2(x - centerX, centerY - y);
            rotation = (int) Math.toDegrees(r);
        }