Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android animation to rotate a view and freeze it after rotation

I am new to Android Animation and want to do a basic animation

  1. Rotate a view by 180deg

    <set xmlns:android="http://schemas.android.com/apk/res/android">
    <rotate
        android:fromDegrees="0"
        android:toDegrees="180"
        android:pivotX="50%"
        android:pivotY="50%"
        android:duration="300"
        android:fillAfter="true"
        android:fillEnabled="true"
         />
    

but the problem is after animation is done the view returns to its original position i want the view to be 180deg rotated after animation is done

I also added a AnimationListener with onAnimationEnd to do it but it gives some glitch

like image 470
inni Avatar asked Dec 20 '14 06:12

inni


People also ask

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.

How do I stop Rotationanimation?

rotate); objectImg. startAnimation(myAnim); When a button is pressed, the rotation must stop. Hence in my onClick(), I called clearAnimation().


1 Answers

hey use this ....

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
    android:fillAfter="true"
    android:fillEnabled="true">

<rotate
    android:duration="1000"
    android:fromDegrees="0"
    android:pivotX="50%"
    android:pivotY="50%"
    android:toDegrees="180" />

 </set>
like image 166
Sanket Avatar answered Oct 20 '22 10:10

Sanket