Skip to content

Instantly share code, notes, and snippets.

@Mustufa786
Created August 5, 2019 07:28
Show Gist options
  • Save Mustufa786/e2c37a63191b27ac8d51c127453f9bff to your computer and use it in GitHub Desktop.
Save Mustufa786/e2c37a63191b27ac8d51c127453f9bff to your computer and use it in GitHub Desktop.
private void FromLeftToRight(View itemView, int i) {
if(!on_attach){
i = -1;
}
boolean not_first_item = i == -1;
i = i + 1;
itemView.setTranslationX(-400f);
itemView.setAlpha(0.f);
AnimatorSet animatorSet = new AnimatorSet();
ObjectAnimator animatorTranslateY = ObjectAnimator.ofFloat(itemView, "translationX", -400f, 0);
ObjectAnimator animatorAlpha = ObjectAnimator.ofFloat(itemView, "alpha", 1.f);
ObjectAnimator.ofFloat(itemView, "alpha", 0.f).start();
animatorTranslateY.setStartDelay(not_first_item ? DURATION : (i * DURATION));
animatorTranslateY.setDuration((not_first_item ? 2 : 1) * DURATION);
animatorSet.playTogether(animatorTranslateY, animatorAlpha);
animatorSet.start();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment