I used this example to create a background animation for my project.
final LinearLayout backgroundOne = (LinearLayout) findViewById(R.id.background_one);
final LinearLayout backgroundTwo = (LinearLayout) findViewById(R.id.background_two);
final ValueAnimator animator = ValueAnimator.ofFloat(0.0f, -1.0f);
animator.setRepeatCount(ValueAnimator.INFINITE);
animator.setInterpolator(new LinearInterpolator());
animator.setDuration(1500L);
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
final float progress = (float)
animation.getAnimatedValue();
final float width = backgroundOne.getWidth();
final float translationX = width * progress;
backgroundOne.setTranslationX(translationX);
backgroundTwo.setTranslationX(translationX + width); } });
animator.start();
However, I was only able to move it horizontally to the right and left. Would anyone have any idea how to move vertically?