Tip:
Highlight text to annotate it
X
NICK BUTCHER: Hi, I'm Nick Butcher, an engineer on the
Android Developer Relations team.
I'm going to show you a quick trick for your activity
animations.
So by default, when you switch screens, Android will show an
animation between those two screens.
A slight variation on the standard animation is using a
grow up, grow down animation, which helps you to retain some
context where the users come from.
You might be familiar with this
from the Recents animation.
But you can use it in your own app.
So here for example, I have a grid layout.
And if I touch on one of these tiles, this top right one,
it'll grow up from where I touched.
And if I go from around here, it'll grow from there.
So it helps to retain context.
I've slowed this animation down using one of the tricks,
using one of the settings in Developer Options called
Transition Animation Scale just to
demonstrate this better.
If I turn that off and go back, you'll
see it's pretty subtle.
But it really does help remember where
the user came from.
Best of all, this is incredibly easy for you to do
in your code.
So here we are.
I'm creating a bit map to scale from.
So here, it's just a simple color for my demo.
And then you just use the static method on Activity
Options to call Make Scale Up Animation.
And passing it the view to scale from the bit map from
the outer scale from--
and it will return you a bundle.
You pass this bundle to your call to start activity.
And this will perform the animation for you--
couldn't be easier.
One slight variation, which I've commented out here you
can see in the code, is to scale up just from a view
without the thumbnail options, so if you don't have a
thumbnail to scale from.
This is slightly different.
You'll have to do a fade animation as
well as the grow animation.
So you have a slightly different effect.
But if you don't have a thumbnail to scale from, you
can use this.
Thanks very much.