Created
January 15, 2018 06:31
-
-
Save hilfritz/bc97f6844343b3a36d17637a08ab8881 to your computer and use it in GitHub Desktop.
Android show/hide view with fade
This file contains hidden or 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 animateCountdown(final View textView){ | |
| ValueAnimator valueAnimator = ValueAnimator.ofFloat(1f, 0f); | |
| valueAnimator.setDuration(800); | |
| valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { | |
| @Override | |
| public void onAnimationUpdate(ValueAnimator animation) { | |
| float alpha = Float.parseFloat(animation.getAnimatedValue().toString()); | |
| textView.setAlpha(alpha); | |
| } | |
| }); | |
| valueAnimator.start(); | |
| } | |
| private void animateShow(final View view){ | |
| ValueAnimator valueAnimator = ValueAnimator.ofFloat(0f, 1f); | |
| valueAnimator.setDuration(800); | |
| valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { | |
| @Override | |
| public void onAnimationUpdate(ValueAnimator animation) { | |
| float alpha = Float.parseFloat(animation.getAnimatedValue().toString()); | |
| view.setAlpha(alpha); | |
| } | |
| }); | |
| valueAnimator.start(); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment