【问题标题】:Android animation to rotate a view and freeze it after rotationAndroid动画旋转视图并在旋转后冻结它
【发布时间】:2014-12-20 16:06:40
【问题描述】:

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

  1. 将视图旋转 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 度

我还添加了一个带有 onAnimationEndAnimationListener 来执行此操作,但它会产生一些故障

【问题讨论】:

  • OnAnimationEnd 设置 rotation 的视图。
  • @Yugesh 我尝试使用 onAnimationEnd 旋转视图,但在几分之一秒内,它显示原始位置的视图以及应用旋转的更改
  • 你能帮我写代码吗

标签: android android-layout animation android-animation


【解决方案1】:

嘿,用这个....

<?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>

【讨论】:

    猜你喜欢
    • 2011-05-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多