Last active
November 8, 2018 11:15
-
-
Save mahdi-malv/0ba6c3503cd30e50d6a659db03287f51 to your computer and use it in GitHub Desktop.
Fade in animation for fast splash usage
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
public void singleFadeInView(View v, long duration, final Consumer<Animation> onAnimEnd) { | |
AlphaAnimation anim = new AlphaAnimation(1.0f, 0.0f); | |
anim.setDuration(duration); | |
anim.setAnimationListener(new Animation.AnimationListener() { | |
@Override | |
public void onAnimationStart(Animation animation) {} | |
@Override | |
public void onAnimationEnd(Animation animation) { | |
onAnimEnd.accept(animation); | |
} | |
@Override | |
public void onAnimationRepeat(Animation animation) {} | |
}); | |
v.startAnimation(anim); | |
} |
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
fun singleFadeInView(v: View, duration: Long, onAnimEnd: () -> Unit) { | |
val anim = AlphaAnimation(0.0f, 1.0f) | |
anim.duration = duration | |
anim.setAnimationListener(object : Animation.AnimationListener { | |
override fun onAnimationRepeat(animation: Animation?) { | |
} | |
override fun onAnimationEnd(animation: Animation?) { | |
onAnimEnd() | |
} | |
override fun onAnimationStart(animation: Animation?) { | |
} | |
}) | |
v.startAnimation(anim) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment