Nestor
Nestor

Reputation: 8384

How to set an offset of ImageView between the animation and its repeat in TranslateAnimation

I have an ImageView, it is in the middle of the screen. I created a TranslateAnimation to move ot to the right edge of the screen with this code:

      logoAnimationLeft2Right = new TranslateAnimation(0, screenWidth/2+imageWidth, 0, 0);
      logoAnimationLeft2Right.setDuration(500);
      logoAnimationLeft2Right.setFillAfter(false);
      logoAnimationLeft2Right.setRepeatMode(Animation.REVERSE);
      logoAnimationLeft2Right.setRepeatCount(1);

Using this, my ImageView goes off to the right edge and the rolls back from the right to the center. I'd like to create an offset to make the ImageView to come back on the LEFT side of the screen and go back to the center (appearing to go "around" the center).

What should I do to make this offset between the animation and its reversed repeat?

Upvotes: 0

Views: 543

Answers (1)

Isaiah
Isaiah

Reputation: 442

Use AnimationSet, contains the animation to the right and the animation to the left side, play then sequentailly and repeatly.

Upvotes: 1

Related Questions