Android animation to rotate the view and freeze it after rotation

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

  • Rotate view 180 degrees

    <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 that after the animation the view returns to its original position, I want the view to be rotated 180 degrees after the animation.

I also added an AnimationListener with onAnimationEnd , but it gives some glitch

+4
source share
1 answer

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>
+5
source

Source: https://habr.com/ru/post/1568435/


All Articles