Reputation: 9736
I have a view with an starting size (Width1 and Height1). I want to create an animation to change its size to the end size (Width2 and Height2). I have been reading about ScaleAnimation but I cannot understand the scaling factor.
Could you please tell me the values a, b, c & d for the constructor:
ScaleAnimation scaleAnimation = new ScaleAnimation(a, b, c, d);
Thanks
Upvotes: 3
Views: 325
Reputation: 14338
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);
Upvotes: 2