动画从一个点到android中的各个位置

时间:2015-05-28 07:03:42

标签: android animation android-animation

我正在制作从0,100到相应位置的动画创建TextView,更多细节图片视图。

从左上角开始,在加载UI时创建textview。

enter image description here
并且,法线表示从顶部移动到textview位置。

enter image description here

以简单的方式,左上角到任何位置动画

提前致谢。

1 个答案:

答案 0 :(得分:0)

您可以使用此方法:

private void translateTextView(TextView textView, int targetX, int targetY) {
        AnimatorSet animSetXY = new AnimatorSet();

        ObjectAnimator y = ObjectAnimator.ofFloat(v,
                    "translationY",textView.getY(), targetY);

        ObjectAnimator x = ObjectAnimator.ofFloat(v,
                    "translationX", textView.getX(), targetX);

        animSetXY.playTogether(x, y);
        animSetXY.setInterpolator(new LinearInterpolator(1f));
        animSetXY.setDuration(300);
        animSetXY.start();
    }