So show of hands, who here has worked with relative
layout? A lot of you.
So then you know that relative layout is a very powerful layout. But it could be a bit
tricky to work with. I hope that you will like this next part of the demo.
Unlike everything else I've shown you, this is not in the version 11 of the Eclipse plug-in
that we're going to release very soon. Our tools, basically all of the source code is
available. You can build it from scratch today what you've seen. We're still doing a bit
of QA on the release. This is the follow-up, so this is a preview to give you a sense of
what we're doing. Here's the relative layout, and I'm going to drag in a text field over
this. As I'm dragging, you can see it's trying to attach this to sort of the nearest edge
or maybe do some centering. So I'm going to drop it around here. And then
I'm going to drag another widget in, a button. And as I'm dragging, you can see that it's
doing a bunch of matching. It's trying to pick a nice edge match for this.
So I'm going to drop the button there. Let's do another text field under it. It's attaching
it right there. And let's put in a label and show you baseline
alignment. So it's doing a baseline alignment of this label. And let's put a spinner below
it. So in addition to giving your geometric matches as you're dropping, I can also reattach
any edge. So I can go and, you know, reattach the right edge over here. I can do the left
edge to here. Or maybe to here. Or to the bottom. Or I can release an edge like this
so that it goes where it wants to go based on the intrinsic height. And, obviously, I
can just reconfigure things. And it makes sure that there are no cycles or any problems
like that. Notice also that as I'm selecting things in
this layout, it's showing me what the attachments are and it's also highlighting dependent nodes
a bit. And I can even turn on visualization of all
the attachments in this relative layout. So let's go back to, for example, this activation
screen. You can see here that, for example, the bottom buttons are bound to the bottom
right, whereas the content pane is attached to the center, and so forth. So that's what
we're working off relative layout. And once we're done with it, I hope you'll
find it very useful. [ Cheers and applause ]
>>Tor Norbyte: So the last visual thing I want to show you is our support for animations.
So in Honeycomb, there's a new animator API. So you have this new animator resource folder.
And if you have animation resources in there, you can open any layout, and you can select
the widget. And when you right click on it, there's this play animation menu. In here,
we show you all the builtin animation as well as the animator resources you've added to
your project. So if I select this, this custom one animation, you can see that we previewed
animation right in the tool. So you can make some tweaks. So if I open this animation file
-- by the way, we have -- we now have code completion on this and documentation, so you
can explore the API a bit. [ Cheers and applause ]
>>Tor Norbyte: So I'm going to insert an interpolator. I'm going to change it to an overshoot interpolator
and jump back here. And now if I rerun the animation, you can
sort of see the overshoot animation. This gives you a good way to play animation and
preview them before actually having to run your application. Notice this animation is
independent of the widget I chose. I can go to this layout and run animation on the entire
layout. It's basically just an animation resource you can apply to any object you want.
The last thing I want to show you is -- >>Xavier Ducrohet: So I just want to mention
something. Because if you start using that, you're probably going to have a problem.
In the resource folder of your application, there's an anim folder. That's where the animation
are supposed to go. At the framework level, they wanted to make a difference between the
old animation framework and the new animation framework. So starting with 3.0, you can actually
put them in res/animation. So it's not really required, you can put them in either animation
folder. But the convention is that you put the old
one in anim and the new one in animation. And that's the only place where edit is going
to go and look for those. So the right-click menu that Tor showed you where we list all
the animation that you have in your project, we're only going to go and look in the new
animation folder. So you should really put them there. If you don't find it, it's just
that you put it in the older folder. So that will help you if you have an issue and don't
find your animations. >>Tor Norbyte: Okay. The last thing I want
to show you is our somewhat improved support for pure XML editing. If you don't want to
use a UI builder, at least you should check this part out.
So if you switch to XML, obviously, we have code completion for the layout types. So I
can insert edit text. And give myself some space. I can complete on, for example, the
text property here. We get documentation. We help you complete framework resources.
We also give you help if you're doing -- if you type strings by hand. So I'm going to
type hello world. Notice that if I invoke the Eclipse quick fix command, which is command
one on Mac and control one on other platforms, we had a quick fix to extract this string.
By the way, all the visual refactorings I showed you before, also available on XML.
Quick fix on the element and you can do your wrap in and so forth right there.
So on a string like this, I can do extract Android string. This is going to give me a
wizard where I can quickly choose the key I want to use. This will basically pull the
string into a resource file. I can also do some completion on the margin.
Notice how you don't have to type the name space prefix. You also don't have to type
the layout underscore prefix. We match them both, give you completion on units with documentation.
Or if you create a nonexistent resource, like this, you get an error, but there also is
a quick fix to correct this error. So here we have a missing dimension. So if I invoke
this quick fix, it goes to the dimensions file and adds an entry for me to customize.
And we also help you with flags. So, for example, for the text field, there's a bunch of flags
you may want to set. And we help you with, basically, picking all the various attributes
you may want to add to this flag. Now, we also have support for go to declaration
pervasively within the tool. So, obviously, I can hold the control key and hover over
here and I can jump to the string that we just extracted. And if you have many definitions
of a resource, for example, notice how if I hover over this okay, it instantly shows
me all the locations where this string is defined, all of the message catalogues so
I can quickly, for example, go to the German definition of okay, which is same as English,
I guess. [ Laughter ]
>>Tor Norbyte: And this works not just from layout XML files. It works everywhere. So
if I open the manifest file, for example, I can jump to the drawable resource that's
going to open it. That's the app icon. I can jump to a permission that opens the documentation
for that permission. I can jump, obviously, to string resources, which I've already shown
you. And I can jump to, for example, the activity or services registered here. So this is going
to jump into the Java code. And within the Java code as well, if I, for
example, hover over this layout, you can see that it's telling me that this resource is
defined in these multiple layouts here. And even for IDs defined in any inline in any
XML file, it will locate it and go to it for you. So that's basically -- I'm going to turn
it back over to Xavier. [ Cheers and applause ]
Log in to save your progress and obtain a certificate in Alison’s free Fundamentals of Google Android Development online course
Sign up to save your progress and obtain a certificate in Alison’s free Fundamentals of Google Android Development online course
Please enter you email address and we will mail you a link to reset your password.