【发布时间】:2017-12-05 04:47:31
【问题描述】:
我想在曲线中平移图像视图,同时在平移时对其进行缩放。
我经历过 多个帖子喜欢 https://stackoverflow.com/a/30254927/3518278 我不知道如何计算我的路径变量
还有 它在这里提到,android 5 提供了极坐标中的基本曲线 https://stackoverflow.com/a/26591870/3518278 但它们似乎没有效果。
我当前的代码是
View view;
ValueAnimator animator = ValueAnimator.ofFloat(0, 1); // values from 0 to 1
animator.setDuration(5000); // 5 seconds duration from 0 to 1
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener()
{
@Override
public void onAnimationUpdate(ValueAnimator animation) {
float value = ((Float) (animation.getAnimatedValue()))
.floatValue();
// Set translation of your view here. Position can be calculated
// out of value. This code should move the view in a half circle.
img_fullscreen_drone.setTranslationX((float)(150.0 * Math.sin(value*Math.PI)));
img_fullscreen_drone.setTranslationY((float)(150.0 * Math.cos(value*Math.PI)));
img_fullscreen_drone.setScaleType(ImageView.ScaleType.CENTER);
img_fullscreen_drone.animate().scaleX(0.5f).scaleY(0.5f).setDuration(5000).start();
}
});
animator.start();
这会将我的视图转换为弧形,但在平移完成后开始缩放,我希望缩放和沿曲线平移同时发生。
如有任何帮助,我们将不胜感激
提前致谢
【问题讨论】:
标签: android