Reputation: 20223
I have a imageView in Center_Horizontal and Center_Vertical of my screen. I would like to make a zoom in this image and that the zoomed image stay still on the midle of th screen.
The problem is that the ScaleAnimation will make the image larger and higher from the top left corner, so my image will not be in the middle of the screen.
I readed something abaut the XPivot and yPivot in ScaleAnimation but I don't understand their use.
My goal is to zoom the image from the middle of the image and not from the left corner.
I hope my question is understandable.
Thank you for your help.
Upvotes: 0
Views: 714
Reputation: 46
The pivot values establish the central point at which the ScaleAnimation will take place. Assuming your image is centered in your view, you can use the following:
ScaleAnimation sa = new ScaleAnimation(1, 2, 1, 2
, Animation.ABSOLUTE
, getWidth()/2
, Animation.ABSOLUTE
, getHeight()/2
);
The pivot values will be set to the center of your physical display. You can use different pivot type values such as RELATIVE_TO_PARENT if appropriate to your application.
Upvotes: 2