android - 旋转动画功能,
问题描述
我被问到如何在旋转动画中获得旋转角度。
我的最终目标是根据运行轮盘赌设定的角度向微控制器发送信号。
我使用以下代码检查了旋转图像角度的日志:
objectAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator valueAnimator) {
double angle = Double.parseDouble(objectAnimator.getAnimatedValue().toString());
Log.d("LOG", "animation : " +
}
catch (Exception e){
}
}
});
//setDuration -> 360
//range -> 0~360
//setInterpolator -> LinearInterpolator
日志如下所示。
D/LOG: animation : 0.0
D/LOG: animation : 0.0
D/LOG: animation : 33.0
D/LOG: animation : 49.0
D/LOG: animation : 66.0
D/LOG: animation : 83.0
D/LOG: animation : 99.0
D/LOG: animation : 133.0
D/LOG: animation : 150.0
D/LOG: animation : 166.0
D/LOG: animation : 183.0
D/LOG: animation : 216.00002
D/LOG: animation : 233.0
D/LOG: animation : 249.99998
D/LOG: animation : 266.0
D/LOG: animation : 283.0
D/LOG: animation : 316.0
D/LOG: animation : 333.0
D/LOG: animation : 350.0
D/LOG: animation : 360.0
我没有使用 LinearInterpolator 设置对图像旋转进行任何加速或减速。
我发现动画帧速率调用了onAnimationUpdate。(一定不?)
我想知道绝对角度,而不是动画更新时的角度。
我能怎么做?
还有其他方法可以制作旋转动画并获得绝对角度吗?
谢谢
解决方案
推荐阅读
- python - 自合并后 Pandas 数据框中的重复项
- css - 为导航选项卡中的选项卡添加背景
- javascript - 从数组填充 Bootstrap 4 表?
- angular - Angular - 找不到错误源,因为堆栈跟踪在生产模式下被混淆了
- javascript - 如何在Angular 6中设置背景图像图像路径
- node.js - vue-cli · 下载 repo vuejs-templates/webpack 失败:证书链中的自签名证书
- json - 使用 Laravel,有没有一种方法可以在一个 ajax 调用上运行多个模型的数据验证?
- machine-learning - 对于 98% 的列都是空值的数据集,我们可以做什么?
- ios - Swift中'_ in print()'的含义是什么?
- android - Flutter - 我运行 print(myFile.absolute.path) 时 myFile 不在范围内