简体   繁体   中英

Rotate 2d image onclick android

i want to rotate the image of imageView, i have scaled the image using matrix but having problem in rotation, i'm using the code...

int previousDegrees = 0;
        int degrees = 90;
        RotateAnimation animation = new RotateAnimation(previousDegrees,degrees,160,160);
        ImageView imageView = (ImageView)findViewById(R.id.imageView);
        animation.setDuration(1000);//Set the duration of the animation to 1 sec.
        imageView.startAnimation(animation);

it rotates the image for a second and setback to original position.. is there any way that image could rotate onclick continuosly.. like on (0,90.180.270,360)degrees... Any Help please!!!

Set these parameters like so:

    animation.setFillEnabled(true);
    animation.setFillAfter(true);

From Android Developers Reference :

If fillAfter is true, the transformation that this animation performed will persist when it is finished.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM