letsCode
letsCode

Reputation: 3046

why wont his imageview rotate?

I am trying to rotate an image view at its center. When I click on the image, it wont rotate. Any reason why?

        refreshResults.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            RotateAnimation anim = new RotateAnimation(0.0f, 360.0f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
            anim.setInterpolator(new LinearInterpolator());
            anim.setRepeatCount(Animation.INFINITE);
            //how to start it.
            refreshResults.startAnimation(anim);
        }
    });

Upvotes: 0

Views: 30

Answers (1)

Unique Identifier
Unique Identifier

Reputation: 370

Try this its working for me.

RotateAnimation myAnim = new RotateAnimation(0, 45, Animation.RELATIVE_TO_SELF,
            0.5f, Animation.RELATIVE_TO_SELF, 0.5f);

myAnim .setInterpolator(new LinearInterpolator());
myAnim .setDuration(500);
myAnim .setFillEnabled(true);
myAnim .setFillAfter(true);

image.startAnimation(myAnim )

Upvotes: 1

Related Questions