Reputation: 375
I'm using this code to moving view from x Position to another x Position :
int xStart=100,xEnd=500;
ObjectAnimator objectAnimator= ObjectAnimator.ofFloat(view, "translationX", xStart, xEnd);
objectAnimator.setDuration(duration);
objectAnimator.start();
but i need moving and rotating .
how can Rotate and move the view together ?
It is possible ?
Upvotes: 1
Views: 479
Reputation: 67189
You can use ObjectAnimator
to animate any property of a View- essentially any property with set___()
and get___()
methods.
For rotation, you can use "rotation"
, "rotationX"
, and "rotationY"
as appropriate.
It sounds like you already have translation working correctly, so I'm not sure what else you are looking for in "moving" the View.
To play multiple animations together, you can use an AnimatorSet
. To move and rotate at the same time, you might do this:
AnimatorSet animations = new AnimatorSet();
ObjectAnimator translationAnim= ObjectAnimator.ofFloat(view, "translationX", 100, 500);
ObjectAnimator rotationAnim = ObjectAnimator.ofFloat(view, "rotation", 0, 90);
animations.play(rotationAnim).with(translationAnim);
animations.start();
For more information see the Property Animation documentation.
Upvotes: 1