使用Nineoldandroids向后移植缩放视图-方法未解决



我正在尝试端口http://developer.android.com/training/animation/zoom.html回到API<11.

我正在使用nineoldandroid库来做这件事。然而,有一部分nineoldandroid无法理解:

        AnimatorSet set = new AnimatorSet();
        set.play(ObjectAnimator
                .ofFloat(expandedImageView, View.X, startBounds.left))
                .with(ObjectAnimator
                        .ofFloat(expandedImageView,
                                View.Y, startBounds.top))
                .with(ObjectAnimator
                        .ofFloat(expandedImageView,
                                View.SCALE_X, startScaleFinal))
                .with(ObjectAnimator
                        .ofFloat(expandedImageView,
                                View.SCALE_Y, startScaleFinal));

我把它做成了:

AnimatorSet set = new AnimatorSet();
set.playTogether(
        ObjectAnimator.ofFloat(expandedImageView, View.X, startBounds.left, finalBounds.left),
        ObjectAnimator.ofFloat(expandedImageView, View.Y, startBounds.top, finalBounds.top),
        ObjectAnimator.ofFloat(expandedImageView, View.SCALE_X, startScale, 1f),
        ObjectAnimator.ofFloat(expandedImageView, View.SCALE_Y, startScale, 1f)
);

但是,不接受View.X、View.Y、View.SCALE_X和View.SCALE_Y。

是否应将其替换为字符串"translationX"、translationY和"scaleX"、"scaleY"?

我最初的猜测是对的,但不需要playTogether。

这就是解决方案:

set
        .play(ObjectAnimator.ofFloat(expandedImageView, "translationX", startBounds.left, finalBounds.left))
        .with(ObjectAnimator.ofFloat(expandedImageView, "translationY", startBounds.top, finalBounds.top))
        .with(ObjectAnimator.ofFloat(expandedImageView, "scaleX", startScale, 1f))
        .with(ObjectAnimator.ofFloat(expandedImageView, "scaleY", startScale, 1f));

最新更新