Activity transition in Android
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Introduction
Activity transitions in Android control how one screen enters while another exits. Good transitions make navigation feel intentional, while bad ones feel jarring or slow. The core choices are simple custom animations, shared element transitions, and using the right API so the effect works consistently across the app.
Basic Activity Launch
At the simplest level, one activity starts another with an Intent.
That alone works, but it uses the default transition chosen by the system theme.
Apply Custom Enter and Exit Animations
If you want a specific slide or fade, provide animation resources and apply them when launching the new activity.
Example animation file:
You normally define two animations:
- how the new activity enters
- how the current activity exits
The same applies when finishing:
That keeps forward and backward navigation visually consistent.
Use Shared Element Transitions for Visual Continuity
When one view on the first screen should appear to continue into the second screen, shared element transitions work better than generic slides.
The destination activity needs a matching transition name:
This is especially effective for gallery, profile, and card-to-detail flows.
Theme-Based Window Transitions
Android also supports transitions through window theme attributes. That is useful when you want consistent activity behavior without repeating code in every launch call.
With theme-based transitions, you can define enter and exit behavior at the window level and keep launch code cleaner.
Know When to Use Fragment Transitions Instead
Not every screen change should be an activity transition. If the navigation happens inside one activity, fragment transitions are often a better fit. They are usually easier to coordinate with shared view models, bottom navigation, and modern single-activity app structures.
Use activity transitions when:
- the app truly moves between activities
- the screens have distinct lifecycle boundaries
- the architecture already uses multiple activities
Use fragment or Compose navigation transitions when the flow stays inside one host activity.
Keep Transitions Fast and Consistent
Good transition design is more about restraint than novelty. Fast, consistent animations feel better than long dramatic ones.
Practical guidelines:
- keep durations short
- animate a small number of elements
- use the same direction logic across similar screens
- test on low-end devices
A slow transition that blocks interaction is worse than no transition at all.
Common Pitfalls
One common problem is defining nice animation XML but forgetting to call overridePendingTransition, so the custom resources are never used.
Another issue is using heavy animations on complex layouts, which can cause dropped frames and make navigation feel slower.
Shared element transitions also fail easily if transition names do not match exactly between source and destination views.
Summary
- Activity transitions define how one Android screen enters and another exits.
- Use
overridePendingTransitionfor straightforward custom enter and exit animations. - Use shared element transitions when a specific view should visually continue across screens.
- Prefer fragment or Compose transitions if the app flow stays inside one activity.
- Keep animations short, consistent, and light enough to stay smooth.

