A transition animation is a visual effect that smoothly changes the UI from one state or screen to another, making the change feel natural and engaging.
Click to reveal answer
beginner
Name two common types of transition animations in Android.
1. Activity transitions (between screens)
2. Shared element transitions (animating a common element between screens)
Click to reveal answer
intermediate
Which Android class is used to define a shared element transition?
The class is `Transition` from the `android.transition` package, often using subclasses like `ChangeBounds` or `Fade`.
Click to reveal answer
intermediate
How do you start an activity with a transition animation in Kotlin?
Use `ActivityOptionsCompat.makeSceneTransitionAnimation()` to create options, then pass it to `startActivity(intent, options.toBundle())`.
Click to reveal answer
beginner
Why are transition animations important in mobile apps?
They improve user experience by making navigation feel smooth and intuitive, helping users understand changes and focus on content.
Click to reveal answer
Which method is used to create a shared element transition animation in Android?
A. Animation resource IDs must be strings, not integers
B. Incorrect method name; should be setPendingTransition
C. Missing second animation resource parameter in overridePendingTransition
D. startActivity should be called after overridePendingTransition
Solution
Step 1: Check the method signature of overridePendingTransition
This method requires two parameters: one for the enter animation and one for the exit animation.
Step 2: Identify the missing parameter
The code only provides one animation resource, causing a compile-time error.
Final Answer:
Missing second animation resource parameter in overridePendingTransition -> Option C
Quick Check:
overridePendingTransition needs two animations [OK]
Hint: overridePendingTransition always needs two animation IDs [OK]
Common Mistakes:
Providing only one animation resource
Using wrong method names
Calling overridePendingTransition before startActivity
5. You want to create a smooth slide transition when moving from MainActivity to DetailActivity. You have two animation XML files: slide_in_right.xml and slide_out_left.xml in res/anim/. Which code snippet correctly applies these animations during the activity transition?
hard
A. overridePendingTransition(R.anim.slide_in_right, R.anim.slide_out_left)
startActivity(Intent(this, DetailActivity::class.java))
B. startActivity(Intent(this, DetailActivity::class.java))
overridePendingTransition(R.anim.slide_in_right, R.anim.slide_out_left)
C. startActivity(Intent(this, DetailActivity::class.java))
overridePendingTransition(R.anim.slide_out_left, R.anim.slide_in_right)
D. startActivity(Intent(this, DetailActivity::class.java))
overridePendingTransition(R.anim.slide_in_left, R.anim.slide_out_right)
Solution
Step 1: Confirm the order of method calls
You must call startActivity first, then overridePendingTransition immediately after.
Step 2: Match animations to correct enter and exit roles
slide_in_right is the enter animation for the new activity, and slide_out_left is the exit animation for the current activity.
Final Answer:
startActivity(Intent(this, DetailActivity::class.java))
overridePendingTransition(R.anim.slide_in_right, R.anim.slide_out_left) -> Option B
Quick Check:
startActivity then overridePendingTransition with correct animations [OK]
Hint: Enter animation first, exit animation second after startActivity [OK]
Common Mistakes:
Swapping enter and exit animations
Calling overridePendingTransition before startActivity
Using wrong animation resource names
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.