Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ImageView will reset to original state after rotating? [duplicate]

Possible Duplicate:
Android: Animation Position Resets After Complete

I'm using RotateAnimation to rotate an ImageView. The code is simple:

this.button.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View view) {
        Animation ani = new RotateAnimation(
                0, /* from degree*/
                30, /* to degree */
                Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
        ani.setDuration(1000);
        imageView.startAnimation(ani);
    }
});

You can see I want the imageView rotate 30 degree.

It works, but when rotating is done, the image go back to the original state, the same position and degree before rotating. I want to fix ImageView at last Animation position i.e want to fix the image tilted by 30 degree. How to fix it?

like image 921
Freewind Avatar asked Aug 28 '12 09:08

Freewind


1 Answers

I just find an solution:

ani.setFillAfter(true);

It works :)

like image 69
Freewind Avatar answered Oct 15 '22 02:10

Freewind