Maintain centre of custom imageview resized in android

81 views Asked by At

I'm manually resizing a custom imageview by dragging out the bottom right corner by overriding the OnTouch event using the action_move. What i'd like to do is keep the centre point of the image. Just like pivoting on the centre without using the scaling option. I can't use scaling as I'm drawing within the same canvas and I don't want these other images scaled.

Upon moving I calculate the distance I need to resize the image then set the width and height as below. However, this always increases the size from the top left of the image.

this.getLayoutParams().width = newWidth;
this.getLayoutParams().height = newHeight;

What I'd like to do is size the image equally on all sides keeping the centre point of the image at the same co-ordinates.

Also, the image can be at any angle.

0

There are 0 answers