Created
August 5, 2019 07:45
-
-
Save Mustufa786/0dea995a1576cbbdba9a564d255f2cf0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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