How to make the image rotate around a fixed point when using a bitmap?

I am trying to rotate the image at a fixed point, but the image rotates in the upper left position. I tried rotateAnimation and it works great, but the problem is that when I rotate my image again, it starts to rotate from its original position.

Bitmap bmp = BitmapFactory.decodeResource(getResources(), R.drawable.arw2);
int w = bmp.getWidth();
int h = bmp.getHeight();
float px = 160,py = 215;
Matrix mtx = new Matrix();
mtx.setRotate(rAngle, px, py);
Bitmap rotatedBMP = Bitmap.createBitmap(bmp, 0, 0, w, h, mtx, true);
BitmapDrawable bmd = new BitmapDrawable(rotatedBMP);
myImageView.setImageDrawable(bmd);

What am I doing wrong?

+3
source share
1 answer

If I understand your question correctly, you want it to be able to rotate the image once, and then a second time, from where it stopped.

, 30 , 30 ( 60 ), , .

rAngle, , . 30 30 60 90 ..

, 30 , , buttonClicks, rAngle = buttonClicks * 30 .

0

Source: https://habr.com/ru/post/1751339/


All Articles