Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: Rotate animation get back to its real state after finishing the animation?

I am going to rotate the image in My app. All Works fine with the Rotation. But while i rotation animation get finish the Image wil return to its previous position. I want is to remain that image to that rotated state and not to get it back to its real state.

So how to make it possible? To rotate image I am using below code:

    <?xml version="1.0" encoding="utf-8"?>

<rotate xmlns:android="http://schemas.android.com/apk/res/android"
    android:pivotX="50%" 
    android:pivotY="50%" 
    android:fromDegrees="0"
    android:toDegrees="30"
    android:duration="2000">

</rotate>

and applying it to the ImgeView like:

myImageView.startAnimation(rotateRight);

So, Help me regarding this.

like image 742
Shreyash Mahajan Avatar asked Apr 18 '12 05:04

Shreyash Mahajan


People also ask

How do I stop infinite animation?

Use clearAnimation() to stop an animation. There is no loadAnimation() on View .

What is Transition animation in android?

Android's transition framework allows you to animate all kinds of motion in your UI by simply providing the starting layout and the ending layout.

What is animation rotation?

android.view.animation.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.


1 Answers

See How can I animate a view in Android and have it stay in the new position/size?

Inside the <set tag, use

android:fillAfter="true"
android:fillEnabled="true"

In general, Animation does not alter the actual properties of the View, it only animates it. If you want to change the actual properties, use AnimationListener and listen for onAnimationEnd and make the changes yourself.

like image 51
Rajesh Avatar answered Sep 29 '22 17:09

Rajesh