Nguyen Nguyen
Nguyen Nguyen

Reputation: 47

image flip effect using animation in android

I'm currently working on an Android game

I want to create an image flip effect using animation. How would I do it?

Upvotes: 0

Views: 7587

Answers (3)

Nelson
Nelson

Reputation: 424

I managed to achieve this using setScaleX (for flip/reflection around the Y axis). Use setScaleY for flip/reflection around the X axis.

final ValueAnimator rotation = ValueAnimator.ofFloat(0, 360);

Then in your onAnimationUpdate function, set scale on X or Y using the cosine function on your range of angles.

view.setScaleX((float)Math.cos(Math.toRadians((Float)valueAnimator.getAnimatedValue())));

Hope this helps

Upvotes: 0

Rawkode
Rawkode

Reputation: 22592

There is a good example of such here

Upvotes: 2

Related Questions