我正在尝试实现弯曲运动效果 http://developer.android.com/training/material/animations.html#CurvedMotion
这是我的代码,它只是从我的开始合作到我的结尾合作线性动画我的视图 - 没有曲线。我错过了什么?
HomeView homeView = (HomeFragment) adapter.getFragmentAtPosition(MainTab.HOME.getPositionId());
//ending x co-ordinates
float x1 = fab.getX();
float y1 = fab.getY();
//ending x co-ordinates
float x3 = homeView.getCenterXofStatusCard(fab);
float y3 = homeView.getCenterYofStatusCard(fab);
final Path path = new Path();
path.moveTo(x1, y1);
final float x2 = (x3 + x1) / 2;
final float y2 = (y3 + y1) / 2;
path.cubicTo(x1, y1, x2, y2, x3, y3);
ObjectAnimator anim = ObjectAnimator.ofFloat(fab, View.X, View.Y, path);
anim.start();
答案 0 :(得分:4)
我使用的是生成直线贝塞尔曲线的坐标。这里有更好的坐标来创建曲线。
path.moveTo(x1, y1);
final float x2 = (x1 + x3) / 2;
final float y2 = y1;
path.quadTo(x2, y2, x3, y3);