android - 防止旋转动画在取消时重置

标签 android animation frame rotateanimation

我有一个简单的RotateAnimation来无限期地为ImageView设置动画,直到我停止它。我的动画设置如下:

    Animation spin = new RotateAnimation(0.0f, 1800.0f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
    spin.setInterpolator(new LinearInterpolator());
    spin.setRepeatCount(Animation.INFINITE);
    spin.setDuration(5000);
    imageView.setAnimation(spin);

当我调用imageView.cancelAnimation()时,我是否可以将动画“卡住”在它结束的任何帧(或它所在的任何角度),而不是将其重置为第一帧?

最佳答案

我有一个应用程序,在达到确定的角度后必须保持其旋转位置。我搜索了很长一段时间,终于发现调用 setFillAfter() 方法。这将阻止旋转重置。

    RotateAnimation rotate = new RotateAnimation(startingPoint, value, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
    image.setAnimation(rotate);

    rotate.setDuration(ROTATION_INTERVAL);
    rotate.setFillAfter(true);

关于android - 防止旋转动画在取消时重置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8846125/

相关文章:

css - Angularjs ng-view 动画不会在第一次更改时添加 ng-enter 类 - 误解、错误、解决方法?

ios - UITableView 在 reloadData 时消失了

javascript - 如何从 jQuery 访问框架(非 iframe)内容

ios - 如何为 UITableViewCell 实现摇动动画

html - IE 中的翻转动画支持

python - 如何选择 tkinter 框架的坐标?

java - Drawable.createFromStream 和 getResources().getDrawable,为什么它们的输出不同?

android - 同时激活 WiFi 和蜂窝网络接口(interface)

android phonegap相机和图像上传

android - 让 Activity 只是一个弹出窗口