Porting zooming a view back with Nineoldandroids - method not resolved

215 Views Asked by At

I'm trying to port http://developer.android.com/training/animation/zoom.html back to API < 11.

I'm using the nineoldandroid library to do so. However there's this part that nineoldandroid cannot understand:

        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));

I've made this into:

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)
);

However the View.X, View.Y, View.SCALE_X and View.SCALE_Y are not accepted.

Should these be replaced with the strings "translationX", translationY" and "scaleX", "scaleY" ?

1

There are 1 best solutions below

0
On BEST ANSWER

My initial guess was right, but the playTogether was not needed.

This was the solution:

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));