Animations & Transitions
Animate views with ViewPropertyAnimator, ObjectAnimator, and AnimatorSet. Add fragment transitions, shared element animations, and spring physics.
Why Animations Matter
Animations make apps feel alive and responsive. They:
- Provide visual feedback for user actions
- Show how screens relate to each other
- Make data changes less jarring
- Help users understand what changed and why
The key rule: animations should serve the UI, not distract from it. Keep them under 300ms.
ViewPropertyAnimator — Quick Animations
The simplest way to animate a view. Chain calls and call start():
// Fade a view out:
binding.tvMessage
.animate()
.alpha(0f)
.setDuration(300)
.withEndAction { binding.tvMessage.visibility = View.GONE }
.start()
// Slide in from bottom:
binding.cardView.translationY = 200f
binding.cardView.alpha = 0f
binding.cardView
.animate()
.translationY(0f)
.alpha(1f)
.setDuration(250)
.setInterpolator(DecelerateInterpolator())
.start()All lessons in this course
- Material Design Basics
- Themes & Styles
- Custom Views
- Animations & Transitions
- Bottom Navigation & Tabs