Guest User

Untitled

a guest
Jun 22nd, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. final LinearLayout backgroundOne = (LinearLayout) findViewById(R.id.background_one);
  2. final LinearLayout backgroundTwo = (LinearLayout) findViewById(R.id.background_two);
  3. final ValueAnimator animator = ValueAnimator.ofFloat(0.0f, -1.0f);
  4. animator.setRepeatCount(ValueAnimator.INFINITE);
  5. animator.setInterpolator(new LinearInterpolator());
  6. animator.setDuration(1500L);
  7. animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
  8. @Override
  9. public void onAnimationUpdate(ValueAnimator animation) {
  10. final float progress = (float)
  11. animation.getAnimatedValue();
  12. final float width = backgroundOne.getWidth();
  13. final float translationX = width * progress;
  14. backgroundOne.setTranslationX(translationX);
  15. backgroundTwo.setTranslationX(translationX + width); } });
  16. animator.start();
Add Comment
Please, Sign In to add comment