I have image which is symmetrical and I want to move it infinitly from right to left smoothly. I tried to use TranslateAnimation but first I have to properly set my image which is quite difficult mainly because this image is using all screen width and I should set negative margins. Are there any other solution? And is there a possibility to move image without moving ImageView?
Finally I made it by my own and the solution is to put 2 images on each other and then measure screen width and use 2 TranslateAnimation, one from screen width to 0 and second one from 0 to -screen width:
TranslateAnimation anim = new TranslateAnimation(0, -screenWidth, 0, 0);
TranslateAnimation anim2 = new TranslateAnimation(screenWidth, 0, 0, 0);
anim.setDuration(5000);
anim.setRepeatCount(Animation.INFINITE);
anim.setInterpolator(new LinearInterpolator());
anim2.setDuration(5000);
anim2.setRepeatCount(Animation.INFINITE);
anim2.setInterpolator(new LinearInterpolator());
backgroundOverlayImage.startAnimation(anim);
backgroundOverlayImage2.startAnimation(anim2);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With