Reputation: 978
I am using a textview Who's position is changed on touch by following code
tvPostText.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
scaleGestureDetector.onTouchEvent(event);
if (event.getPointerCount() == 3) {
tvPostText.setRotation(rotation(event));
} else if (event.getPointerCount() == 1) {
if (event.getAction() == MotionEvent.ACTION_MOVE) {
v.setX(event.getRawX() - v.getWidth() / 2.0f);
v.setY(event.getRawY() - v.getHeight() / 2.0f);
}
}
return true;
}
I am applying rotate animation on it. If i change the location of textview by finger touch then animation in not working properly. can some one suggerst me how can i apply animation on textview even after change of textview Position.
Following is animation code: -
RotateAnimation anim = new RotateAnimation(0.0f, 360.0f , Animation.RELATIVE_TO_SELF, .5f, Animation.RELATIVE_TO_SELF, .5f);
anim.setInterpolator(new LinearInterpolator());
anim.setRepeatCount(Animation.INFINITE);
anim.setDuration(3000);
tvPostText.startAnimation(animRotate);
Upvotes: 0
Views: 7995
Reputation: 4448
Use Animator
ObjectAnimator objectAnimator=ObjectAnimator.ofFloat(tvPostText,"rotation",0f,360f);
objectAnimator.setInterpolator(new LinearInterpolator());
objectAnimator.setDuration(3000);
objectAnimator.setRepeatCount(ValueAnimator.INFINITE);
objectAnimator.start();
Upvotes: 1
Reputation: 83
Try to call clearAnimation()
on your textview after animation is done. It helped me.
Upvotes: 1