Android动画可旋转视图并在旋转后将其冻结

Android动画可旋转视图并在旋转后将其冻结,android,android-layout,animation,android-animation,Android,Android Layout,Animation,Android Animation,我是新手,想做一个基本的动画 将视图旋转180度 <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" androi

我是新手,想做一个基本的动画

  • 将视图旋转180度

    <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"
         />
    
    
    

  • 但问题是,动画完成后,视图将返回到其原始位置 我希望在动画完成后将视图旋转180度

    我还添加了一个带有onAnimationEnd的动画监听器,但它会出现一些小问题

    嘿,用这个

    <?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>
    
    
    
    OnAnimationEnd设置视图的旋转
    rotation
    。@Yugesh我尝试使用OnAnimationEnd旋转视图,但有几分之一秒的时间,它显示了处于原始位置的视图以及应用旋转的更改。您能帮我编写代码吗