Skip to content

Instantly share code, notes, and snippets.

@Mustufa786
Created August 5, 2019 07:45
Show Gist options
  • Save Mustufa786/0dea995a1576cbbdba9a564d255f2cf0 to your computer and use it in GitHub Desktop.
Save Mustufa786/0dea995a1576cbbdba9a564d255f2cf0 to your computer and use it in GitHub Desktop.
private void FromRightToLeft(View itemView, int i) {
if(!on_attach){
i = -1;
}
boolean not_first_item = i == -1;
i = i + 1;
itemView.setTranslationX(itemView.getX() + 400);
itemView.setAlpha(0.f);
AnimatorSet animatorSet = new AnimatorSet();
ObjectAnimator animatorTranslateY = ObjectAnimator.ofFloat(itemView, "translationX", itemView.getX() + 400, 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