cookiemonster
cookiemonster

Reputation: 55

Rotate image left or right onTouch

So I have square in the center of my screen. Right now i have a 2 buttons to rotate left and right.

switch (v.getId()) {

            case R.id.leftClick:
                square.setRotation(square.getRotation() - 90);

                break;

            case R.id.rightClick:
                square.setRotation(square.getRotation() + 90);

                break;

            default:

                break;
        }

I'd like to change it to do so by touch. Possibly by vertical half (the horizontal bottom half) of the screen. If that make sense. I'm also curious if its possible to have an animation go along with the rotation. Any tips? Thank you in advance.

Upvotes: 0

Views: 504

Answers (1)

IntelliJ Amiya
IntelliJ Amiya

Reputation: 75788

@cookiemonster: You can use RotateAnimation for your requirement . RotateAnimation An animation that controls the rotation of an object. This rotation takes place in the X-Y plane. You can specify the point to use for the center of the rotation, where (0,0) is the top left point. If not specified, (0,0) is the default rotation point. Please check below demo link .I hope it will help .

A simple animation to rotate an image with finger touch both left and right.

Upvotes: 1

Related Questions