Created
February 25, 2020 09:46
-
-
Save Ifeo-A/56d3c1000a2b17d8880278286dc42588 to your computer and use it in GitHub Desktop.
Animation Extension Functions
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 View.slideDownToShow(startPosition: Float, duration: Long = 300L){ | |
if (this.visibility == View.GONE || this.visibility == View.INVISIBLE){ | |
this.visibility = View.VISIBLE | |
} | |
val translationAnimation = TranslateAnimation( | |
0f, // fromXDelta | |
0f, // toXDelta | |
- startPosition, // fromYDelta | |
0f // toYDelta | |
) | |
val alphaAnimation = AlphaAnimation( | |
0f, // fromAlpha | |
1f // toAlpha | |
) | |
translationAnimation.duration = duration | |
translationAnimation.fillAfter = true | |
alphaAnimation.duration = duration | |
this.startAnimation(alphaAnimation) | |
this.startAnimation(translationAnimation) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment