【问题标题】:how slow down rotation speed when rotating image using matrix.postRotate?使用matrix.postRotate旋转图像时如何减慢旋转速度?
【发布时间】:2018-08-26 17:02:42
【问题描述】:

我想减慢动画速度,因为我正在使用下面的代码来旋转ImageView

matrix.postRotate(degrees);

【问题讨论】:

标签: android animation matrix imageview


【解决方案1】:

我曾经这样做过,据我记得我最终使用了ValueAnimator。它是这样的:

ValueAnimator animation = ValueAnimator.ofFloat(0f, 90f);
animation.setDuration(1000);
animation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
    @Override
    public void onAnimationUpdate(ValueAnimator updatedAnimation) {
        float animatedValue = (float)updatedAnimation.getAnimatedValue();
        matrix.postRotate(animatedVlaue);
    }
});
animation.start();

免责声明: 上面的数学是默认关闭的,你不能只是 postRotate 完整的动画值,你最终会过度旋转(如果动画值是 1、2、4、9 等,那么你最终会旋转 1、3、7, 16 等)。我找不到相关代码,但我通过跟踪先前的动画值然后只是在该值与当前动画值之间的增量上执行 postRotate 来解决它。

希望这是有道理的!如果没有,请随时发表评论。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-03-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多