1 | initial version |
The process of overlaying a view with animation in Android development using Kotlin involves the following steps:
<?xml version="1.0" encoding="utf-8"?>
<alpha xmlns:android="http://schemas.android.com/apk/res/android"
android:fromAlpha="0.0"
android:toAlpha="1.0"
android:duration="1000"/>
val viewToAnimate = findViewById<View>(R.id.view_to_animate)
val animation = AnimationUtils.loadAnimation(this, R.anim.fade_in)
animation.setAnimationListener(object : Animation.AnimationListener {
override fun onAnimationStart(animation: Animation?) {
// Animation started
}
override fun onAnimationEnd(animation: Animation?) {
// Animation ended
}
override fun onAnimationRepeat(animation: Animation?) {
// Animation repeated
}
})
viewToAnimate.startAnimation(animation)
val fadeIn = ObjectAnimator.ofFloat(viewToAnimate, View.ALPHA, 0f, 1f)
fadeIn.duration = 1000
val translationY = ObjectAnimator.ofFloat(viewToAnimate, View.TRANSLATION_Y, 0f, 100f)
translationY.duration = 500
val set = AnimatorSet()
set.playSequentially(fadeIn, translationY)
set.start()