2

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" に置き換える必要がありますか?

4

1 に答える 1

2

私の最初の推測は正しかったのですが、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));
于 2014-08-30T14:08:36.183 に答える