AndroidEnthusiast
AndroidEnthusiast

Reputation: 6657

Circular scale animation

I'm trying to achieve an animation which scales over a view like this:

Curved animation

At the moment I'm using a scale animation loaded from xml:

This in action looks like this:

Square like scale animation

It scales more like a square.

I was using ObjectAnimator/ValueAnimator with properties before.

Some devices had specific problems with measuring heights for scaling so I reverted to using xml definitions.

Does anyone have any clue how to achieve the above?

Upvotes: 2

Views: 2025

Answers (1)

Farzad119
Farzad119

Reputation: 244

you must define programmatically you ScaleAnimation.

first get radius of your circle(ImageView) at first position(before start Animation). for get radius you can get width of your imageview and then division to 2.

second you must get width and height of your square.

third do it : anim_to = (width_square + height_Square) / radius_circle;

finally set "anim_to" to your ScaleAnimation and start animation like this:

ScaleAnimation my_reveal = new ScaleAnimation(1,anim_to, 1,anim_to, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
my_reveal.setInterpolator(new DecelerateInterpolator());
my_reveal.setDuration(500);
my_circle.startAnimation(my_reveal);

sorry for my bad ENG ;)

Upvotes: 2

Related Questions