android - 流畅的变形动画
问题描述
如何在android中实现平滑的变形动画?
我正在使用自定义视图canvas.draw(path, paint)
的方法在相机预览上渲染多边形形状。OnDraw()
路径正在呈现如下:
for (int i = 0; i < pointList.size(); i++) {
Point currentPoint = adjustedPointList.get(i);
if (i == 0) {
//for the first point, we only have to move to that point
firstPoint = currentPoint;
mPath.moveTo(currentPoint.getX(), currentPoint.getY());
//Animation here
} else {
//otherwise we draw a line between last position and current point
mPath.lineTo(currentPoint.getX(), currentPoint.getY());
//Animation here
}
}
//we have to draw a last line between last and first point
if (firstPoint != null) {
mPath.lineTo(firstPoint.getX(), firstPoint.getY());
//Animation here
}
我尝试了这里ObjectAnimator
的课程,但没有效果。由于这在线程内部不断调用,因此形状会随着帧的变化而变化。这就是我想要在 iOS 中制作像这里一样流畅的动画的地方。我怎样才能对上面图解的渲染做同样的事情?
我还尝试了以下问题的解决方案:
但是没有什么能达到我平滑形状转换甚至动画路径绘制的目的。目前的形状转变非常闪烁。
此外,许多用于 android 的变形动画参考使用位图或 SVG,这对我来说又没用。
我怎样才能在android中实现这个?还是有不同的方法?如果是这样,我想知道关于它的一切。谢谢!
解决方案
推荐阅读
- c# - 如何更改图像填充量方向?
- javascript - 按钮不适用于 JS 插入的 HTML,但适用于纯 HTML
- python - Python spaCy - 参数'string'的类型不正确(预期的str,得到了DataFrame)
- r - What's the correct way to implement a user-defined do.call's what function?
- r - 如何在循环中创建向量
- javascript - 根据选中的复选框显示/隐藏部分
- c - 创建使用递归的程序时遇到问题
- matlab - matlab中的三重求和
- javascript - 如何设置 setInteval 使其适用于特定的子类
- php - 如果是子域,则在 Laravel 5.7 中调用子域 URL 否则域 URL 调用