Skip to content

Instantly share code, notes, and snippets.

@Ifeo-A
Created February 25, 2020 09:46
Show Gist options
  • Save Ifeo-A/56d3c1000a2b17d8880278286dc42588 to your computer and use it in GitHub Desktop.
Save Ifeo-A/56d3c1000a2b17d8880278286dc42588 to your computer and use it in GitHub Desktop.
Animation Extension Functions
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