which tool need use
Beautiful examples The explanation is simple and fast way
Given that when you create a project in Eclipse you should always create it with the most recent version of Android (3.0 in this case) but will android users be able to install/view it on say a version 2.2 device without problems?
>>Tor Norbye: All right. Can we switch to the Mac?
Okay. So this is our new layout WYSIWYG editor. The way you operate with this editor is drag
and drop. So you can go to the palette, you can drag something. And as you can see, as
I am dragging over the canvas, I am getting some feedback. You can see over on the right
there's an outline telling me what the drop target is.
Once I drop it, I can also obviously drag around to reconfigure this view, and I can
even drag over to the outline if I'm trying to target a specific position or a small drop
target or something. And obviously we have unlimited undo, so let me clean that up again.
On the left here you see a palette, and this is giving you a preview of what these widgets
look like for the current theme. So if I switch to some other layouts here that have different
theme, you can see the palette now looks -- you can see sort of a holo theme. Here is another
customized version of the theme. So the palette updates to show you what you
will get. And I can click on a category, so the time and date here, you can see the widgets
in that category or text fields and so forth. One category I want to point out in particular
is the text fields category. If you went to the ProTips session yesterday, you learned
it is very important to set the input type for your text fields. So what we have done
here is we have packaged a text field with a lot of different configurations for different
input types. So if you are going to put -- if you are going
to ask the user for a phone number, for example, don't just drop a plain text field there.
Drop the phone number text field much that's going to set the input type so that when the
user gets an on-screen keyboard, it's not going to have characters. It's going to have
numbers, for example. The last category I want to point out is this
one on the bottom. This is a special category, custom and library views. When you open that,
we scan your project in all of your libraries and we find out if you have any custom view
implementations. As you can see, I have a few here.
So just like the built-in widgets, I can drag these and we get a live preview in the tool.
So here is a tip. If you control click on this you can jump to the code.
So I am opening this custom view class and I am going to edit the custom view a little
bit. So I am going to copy this color definition and drop it down here and let's change the
color to something recognizable. And I am saving and I am going to go back to the layout.
Notice how instantly the layout preview -- [ Applause ]
>>Tor Norbye: So the preview updated. So if you think about it, that's means we're
actually running your custom views inside the IDE. And of course we have do that. How
else could we preview it? And as Xavier said, we do the same thing with the built-in views.
That's how we can ensure that if you have a relative layout in the tool, it is going
to behave exactly the way it does at runtime. So if you have custom views, you might be
a bit concerned at this point. What if your custom view is creating 50 threads or maybe
connecting to a database or something? That's going to crash and burn; right? Yes, it probably
would. Android has already provided special API support
for this. So in your custom view, you can call this
method "is in edit mode." Your custom view obviously extends view, and view has this
method called "is in edit mode." When you run on the phone or tablet or an emulator,
this method is going to return false. But in a tool, this is going to return true.
So what we want to do here is in the tool, maybe you want to do some sample data that
you are showing in the tool, and then if it's false, you might do the real read from database
or something like that. So here, we'll just put some dummy data in
the tools so it looks better. I am going to call the add block method. We will put some
time blocks in this time strip for a couple of different times.
Let me copy and paste this line a few times. And so now when I save this and go back, you
can see that in the tool, we're getting sort of a little preview. And this is now part
of the class. I didn't actually add any time blocks in my layout here. So if I were to
drag in another one of these, you can see we actually get this design time behavior
in the tool. All right. So that's custom views.
[ Applause ] >>Tor Norbye: Thank you.
The next thing I want to explain is our new layout actions bar. So I am going to drag
in a couple of controls here, or widgets. And if you see this area above the Canvas,
there is a toolbar there. This area contains a number of actions that depend on what you
have selected and what the parent layout is. So right now, I am in a linear layout. So
I can, for example, toggle the orientation of this linear layout, or I can change between
match parent and wrap content for the width or height. Or I can play with the gravity
of this button. So, for example, I can right justify it. Or I can modify the weights. So
I can make the middle button stretch and take all the available room or I can distribute
the weights evenly. So if I delete this widget, you can see the other widgets will take up
the available extra room. And again, the layout actions bar depends
on what you have selected. So if I open another layout, this is a widget within a table layout.
You can see in the outline, it says table layout. So now we have other actions here.
There is an action, for example, to add a table row or delete it or to delete the selection
of rows. Above the layout actions bar is our configuration
chooser. So let me open a -- This is a layout that just has a bunch of different controls.
And Xavier told you how we have one -- we actually do the rendering per SDK. So we have
a render target toggle in the configuration chooser, and here I can say I actually want
to see this layout rendered with 1.6. And you can see when I chose it, you can now see
the old classic check-box look for example. However, when you are using this tool, strongly
recommend that even if you are targeting an older version of Android, you want to use
the latest version of rendering target, because as you can see in this example, showing the
system bar is only supported in the latest version. And a number of the features I am
going to show you doesn't properly work with the old versions of layout library until Xavier
finishes back porting it. >>Xavier Ducrohet: So one of the things that
we added starting with 3.0 is the previous version of the rendering library was just
really run to a library, which is why we call it run to a library. It wrote on the bitmap
and some bonding box for all the objections there.
Starting with 3.0, we wanted to add a lot more interactivity, and so we had to really
extend the API between Eclipse and that rendering library so a lot of the things you are going
to see really requires that. So that's what why we're going to go back
and port that back to 2.1 and up, probably, at least to start with. And so suddenly, when
you get that new version of the rendering library for 2.1, let's say, then some of those
feature will suddenly become available when you use 2.1.
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.