ObjectAnimator.ofFloat(...) を使用して、ビューを画面の右上隅に移動しようとしていますが、期待した結果が得られません。ViewTreeListener などを使用して、事前にビューの座標を取得しています。全体の幅の端からオフセットする必要がある x 値は既にわかっています。どちらの次元も、必要な場所に移動できません。関連コード:
開始座標を取得します。現在のビューは次のとおりです。
int[] userCoords = new int[]{0,0};
userControlLayout.getLocationInWindow(userCoords);
//also tried getLocationInScreen(userCoords); same result
userUpLeft = userCoords[0];
userUpTop = userCoords[1];
驚いたことに、呼び出したときに userUpLeft (画面座標であり、親に相対的ではない) と同じ値を取得しますuserControlLayout.getLeft()
。ドキュメントの理解によって異なると予想されます。ともかく...
ObjectAnimators の構築:
//testXTranslate is a magic number of 390 that works; arrived at by trial. no idea why that
// value puts the view where I want it; can't find any correlation between the dimension
// and measurements I've got
ObjectAnimator translateX = ObjectAnimator.ofFloat(userControlLayout, "translationX",
testXTranslate);
//again, using another magic number of -410f puts me at the Y I want, but again, no idea //why; currently trying the two argument call, which I understand is from...to
//if userUpTop was derived using screen coordinates, then isn't it logical to assume that -//userUpTop would result in moving to Y 0, which is what I want? Doesn't happen
ObjectAnimator translateY = ObjectAnimator.ofFloat(userControlLayout, "translationY",
userUpTop, -(userUpTop));
私の理解では、1 つの引数の呼び出しは、変換/移動先の終了座標を指定することと同等であり、2 つの引数のバージョンは、開始点...終了点、または終了点であるということです。両方ともそこに着くことができません。
明らかに、それが何であるかを理解しようとしているだけで、非常に基本的な知識が欠けています。どんなガイダンスでも大歓迎です。ありがとう。