Deepak Goel
Deepak Goel

Reputation: 5684

Rotation of image using ViewAnimation or PropertyAnimation in android

I want to rotate an image in my application in such a manner that it rotate like a simple pendulam and will stop after some time.

How I can achieve it using View Animation or Property Animation in android

I used the below xml for the animation

     <rotate
        android:duration="2000"
        android:interpolator="@android:anim/accelerate_decelerate_interpolator"
        android:fromDegrees="-15"
        android:pivotX="50%"
        android:pivotY="0%"
        android:repeatCount="5"
        android:repeatMode="reverse"
        android:toDegrees="15" />

And below is the code for the animation

    Animation hyperspaceJumpAnimation = AnimationUtils.loadAnimation(this,
            R.anim.rotate);
    firstBell.startAnimation(hyperspaceJumpAnimation);

But the problem is when animation starts it suddenly move to angle -15 and then start animating. And it stops after 5 count suddenly not in smooth way.

So my question is how to resolve this issue

Looking for help.

Upvotes: 0

Views: 213

Answers (1)

dumbfingers
dumbfingers

Reputation: 7089

About -15 degree:

android:fromDegrees="-15"

and

android:toDegrees="15"

These two lines mean your object start from -15 degrees and end with 15 degree. If that are not what you want, just delete them.

For the Smooth way, you may find the fade.xml in your ApiDemo/res/anim folder.

Upvotes: 1

Related Questions