Parameters of 4-floats ScaleAnimation constructor are the following:
fromX Horizontal scaling factor to apply at the start of the animation
toX Horizontal scaling factor to apply at the end of the animation
fromY Vertical scaling factor to apply at the start of the animation
toY Vertical scaling factor to apply at the end of the animation
All values are float--they represent not sizes in pixels, but relative scaling factors.
So to scale from width1
to width2
and from height1
to height2
you need to set:
ScaleAnimation scaleAnimation =
new ScaleAnimation(1f, 1f * width2 / width1, 1f, 1f * height2 / height1);