0
開始矩形から別のビューで定義されたビューを最終的な位置に拡大しようとしています。開始矩形から最終位置へのスケール
私はまっすぐ前方に見えたセットアップアニメーションに次のコードを使用しようとしました:animatedView
はRelativeLayout
の子(レイアウトパラメータは、レイアウトの一部のタイトルビューの下に設定)し、幅と高さの測定値である
float scaleX = 0f;
float scaleY = 0f;
Rect startRect = new Rect(10, 10, 100, 100); // taken from real view position with getLocationOnScreen
final Collection<Animator> animators = new ArrayList<>();
if (animatedView.getMeasuredHeight() != 0) {
scaleX = (float)startRect.width()/animatedView.getMeasuredWidth();
}
if (animatedView.getMeasuredHeight() != 0) {
scaleY = (float)startRect.height()/animatedView.getMeasuredHeight();
}
animatedView.getLocationInWindow(location);
animatedView.setPivotX(startRect.left);
animatedView.setPivotY(startRect.top);
animatedView.setScaleX(scaleX);
animatedView.setScaleY(scaleY);
animators.add(ObjectAnimator.ofFloat(animatedView, View.SCALE_X, 1.0f).setDuration(1000));
animators.add(ObjectAnimator.ofFloat(animatedView, View.SCALE_Y, 1.0f).setDuration(1000));
とlocationは、アニメーション設定の時点で有効な値です。
startRect
によって異なるアニメーションが観察されます。アニメーション表示は、下に表示される場合もあります。startRect
。
(1を変更していない)、最終的に開始矩形位置からビューをアニメーション化する適切な方法は何ですか?RectEvaluatorが可能な解決策の一つであるようだが、それはAPIからのみ利用可能です18.
使用は 'android.animation.RectEvaluator' – pskink
@pskinkは有望に見えます。翻訳とスケールのプロパティを使用して、すべてのステップで結果rectを適用する必要がありますか? – sandrstar
http://pastebin.com/jaXTjGjAをご覧ください。 – pskink