Bummer! This is just a preview. You need to be signed in with a Basic account to view the entire video.
Start a free Basic trial
to watch this video
As a developer, it's important to understand this commonly-used sequence of four activity transitions when going from screen to screen.
Four Types of Activity Transitions:
- Enter Transition
- Exit Transition
- Return Transition
- Re-enter Transition
Documentation
Customize Activity Transitions (with more details about the types of Activity transitions)
-
0:00
Let's take another look at that line we just added.
-
0:04
Notice that we set the enter transition here.
-
0:07
So what does enter mean?
-
0:09
Let's see what other kinds of transitions we can set.
-
0:11
That's type getWindow.set.
-
0:14
And I'm just going start typing transition because it's going to show me.
-
0:18
There's a bunch of different ones we've got.
-
0:19
Enter.
-
0:20
Exit.
-
0:21
Reenter, and return.
-
0:23
Okay, so what do all of these mean?
-
0:25
When we start the album detail activity with a scene transition activity option.
-
0:29
The album detail activity will run the enter transition.
-
0:33
At the same time the album list activity will run its exit transition.
-
0:37
So if we want to customize how the album list goes away, we can set it there for
-
0:41
the exit transition.
-
0:43
Then when the user hits the back button a different pair of transitions
-
0:46
will be played.
-
0:47
The album detail activity will run its return transition.
-
0:50
And then the album list activity will run its re-enter transition.
-
0:55
To be honest, I've been confused by these four transitions for
-
0:58
quite a while until I drew the diagram you've just seen.
-
1:01
Now pause this video, and try to redraw the diagram yourself.
-
1:05
You'll have a much better time working with these transitions afterwards.
-
1:09
To put our theories into practice, let's customize some of the other transitions.
-
1:14
So let's set the return transitions.
-
1:16
So set return transition.
-
1:19
And we'll set it to a new fade transition.
-
1:23
And now, let's go to album list activity.
-
1:26
And we'll set it's exit transition to explode.
-
1:30
So here we have here we have inite transitions.
-
1:34
This is a different name from our starter files.
-
1:36
Let's just refactor this, I'm going to right click, refactor, rename.
-
1:41
We call this set up transitions to be consistent with what we have in our other
-
1:46
class.
-
1:46
Remember that old Boy Scout rule, always leave the campground, or
-
1:50
code cleaner than you found it.
-
1:52
Let's delete this re-enter transition.
-
1:54
We're not going to worry about that right now,
-
1:55
and will set the exit transition to a new explodes transition.
-
2:01
Haven't set to no like it was before it just means that no
-
2:04
transition will be used.
-
2:05
All right so guess what's going to happen here.
-
2:08
Let's run and see.
-
2:11
Okay and as you might expect.
-
2:14
The transitions look different now.
-
2:18
You can set the four types of transitions to any of the built in transitions or
-
2:22
use your own transition classes.
-
2:25
You can also set these to know which means no animation at all.
-
2:29
Also to save your effort and really tries its best to set proper defaults.
-
2:33
That's why we only needed to add one line in the first example.
-
2:36
Once we set the enter transition,
-
2:37
the system will use its reverse is the return transition.
-
2:41
Same story for exit and reenter transitions.
You need to sign up for Treehouse in order to download course files.
Sign up