Java android中的可点击对象动画

Java android中的可点击对象动画,java,android,Java,Android,我想将图像从A点移动到B点,并在移动过程中单击。不仅在开始时,或在结束时,而且在整个过程中。就像一个移动的目标,然后戳来射它 我看到过一些帖子将人们引向object animator和view property animator,但没有例子,我只是不明白如何从文档中做到这一点。有人能给我一个简短的代码片段吗?最好是不使用XML的编程方式。谢谢你的帮助 编辑:事实上我已经设法弄明白了。类似这样,在创建图像img后: final ViewPropertyAnimator animator =

我想将图像从A点移动到B点,并在移动过程中单击。不仅在开始时,或在结束时,而且在整个过程中。就像一个移动的目标,然后戳来射它

我看到过一些帖子将人们引向object animator和view property animator,但没有例子,我只是不明白如何从文档中做到这一点。有人能给我一个简短的代码片段吗?最好是不使用XML的编程方式。谢谢你的帮助

编辑:事实上我已经设法弄明白了。类似这样,在创建图像img后:

    final ViewPropertyAnimator animator = img.animate();    // The magical View
    animator.scaleX(2);         // Zoom
    animator.scaleY(2);
    animator.setDuration(8000);
    animator.x(300).y(500);
试试这个

    ObjectAnimator animator = 
    ObjectAnimator.ofFloat(view, "translationY", view.getTranslationY(), offset).setDuration(300);
    animator.start();
同时,如果需要,可以启动translationY动画。在动画期间,您可以像往常一样单击视图