我想在缩放的同时将ImageView沿着曲线平移。
我已经阅读了多篇文章,例如https://dev59.com/zmsy5IYBdhLWcg3wvgdl#30254927,但我无法弄清如何计算我的路径变量。
此外,https://dev59.com/Cl8e5IYBdhLWcg3wssIV#26591870中提到Android 5提供了基本的插值曲线,但它们似乎没有效果。
我的当前代码是:
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();
这将我的视图在弧线上进行翻译,但在翻译完成后开始缩放,我希望缩放和沿曲线平移同时发生。
任何帮助将不胜感激
提前致谢