Alright, so continuing on from the last
video at this point our projects now
been created. Now different versions of
Android studio startups showing a
different file but here we've got main
activity Kotlin file open, you can see
this here and you can also see activity
underscore main next to it up here in the
tab at the top.
Now sometimes activity underscore main
will be the one initially displayed but
it doesn't really matter, so you just
click on the tab to switch between them
Now if you remember these are the names
that we gave to the files in that last
video or rather the names that Android
studio suggested and we accepted. Now
there's a lot of things to talk about on
the screen and looking at it you might
be thinking well when I start with all
of this, but the thing to keep in mind
with a lot of this is there's a lot of
information on the screen but you don't
really need to understand a lot of it
straight away. Now once we go through the
course for example, you'll understand
what layouts are and widgets and so
forth, we'll cover that in a later
section of the course but just keep in
the back of your mind that this Android
studio application is very powerful and
it doesn't able you to create very
complex applications now you don't need
to know a lot about these advanced
things yet and in fact we're not going
to be using some of them until later in
the course but I will be explaining
things as I go along so if you're keep
in mind that you can understand
everything at once then all of this will
make sense eventually going through some
of the fundamental things I'm going to
show you how to make a few little
changes before the next video where we
start running this particular
application so the first thing I like to
mention on this slide is that a
rendering error that you can get if
you've installed a preview version of
the Android SDK it's a not a good idea
to install a preview version when you're
learning because you can't be sure if
the error is a result of your code or a
bug in the SDK so here's a screenshot
showing an error displaying the activity
underscore main layout using the android N
and preview version from before Android
n was released. Now that doesn't look
good and if that's the first thing you
see when starting Android studio then it
may be a bit scary and off-putting there
are bugs in preview versions after all
if there were no bugs they'd release it
they wouldn't be caught a preview
version anymore but seeing things like
that when you're new to this is scary so
actually if you stop and think about it
it's obvious that the problem isn't
something that you've done because you
haven't entered any code yet so
the bug can't be yours but that doesn't
really help though because you still
don't know what to do about it so as a
general rule avoid preview versions
until you've got a lot of experience and
have become confident in sorting out
problems now it is possible that you'll
get a rendering error even if you're not
using the preview version that does
happen from time to time and the
particular error I'm thinking of is
similar to this that I'm showing on the
screen now. So if you get that the fix is
to go to the file menu and choose the
option to invalidate caches restart
alright so back in Android studio so if
you do see that error that I showed you
immediately after creating a new project
or opening one that was previously
working and just come up this far menu
and select invalidate case restart this
one here and that should actually fix
the problem but the good news is that
errors like that seem to be less common
in Android studio 3 however keep in mind
that Google changes things all the time
and they do sometimes introduce new bugs
all right so let's have a look now it's
what some of these other things are so
I'm going to start with the layout so
I'm going to click on the activity of a
schoolmate then bring the layout on the
screen you can see at the top there are
a few buttons the first one I want to
draw your attention to is the button
that lets you choose which version of
Android is used for the display so it's
the button on the left above the images
when you're editing a layout file and
the one with a picture of the Android
another number 26 so this one here click
on that, so as you can see I've got API
26, 25, 24 I can switch to those versions if I want to do
but generally I recommend you only need
to specify the latest released version
and only have that version on your
computer and just in case it's not
obvious you do need to install the SDK
for any version that you want to use for
the preview. Now the other thing is you
may recall when we set up the wizard it
asks for names and we left the layout
they must a default activity underscore
main now a layout is a file that
specifies how the various parts of the
screen and laid out Android studio that
you modify the layout either by using
this so graphical designer or by
modifying the XML that represents all
the objects on the screen
so think of a layout as a screen
definition and by changing the layout
you define what the screen looks like
and what it contains. Now over to the
left here are all the various widgets
that we can add to the screen so you can
see there's text widgets there's various
buttons come up here you can see there's
a button the toggle button or radio
button and there's other things also
like progress bars and spinners and
actually scrolling down you can see this
there's quite a list of different
widgets you can add text fuels for
getting inputs various containers and
image widgets and a whole host of other
things you can use when creating the
screens for your apps. So you can make
a lot of changes in this design view by
simply dragging widgets onto the layout
so for example I can come back up to
button and I can just come over here
just drag literally drag the button onto
the layout like so then release it we'll
be doing that soon so I'm just going to
delete that for the other you can also
edit the XML which is the format that
the file is stored in so if I come down
here and click on text this is the XML
representation of our layout now with
Android studio 2.2 Google set out to
make it possible to create even
complicated layouts without ever having
to modify the XML and they've almost
succeeded there's still at least one
reason that you need to edit the XML
unless you want to scrap the entire
layout and start again but on the whole
you don't have to edit this XML view to
get things done very often it could be a
quicker way to create multiple similar
widgets such as an array of buttons for
a calculator app for example but you can
achieve just about everything else when
the help without actually having to know
XML now if you already are familiar with
XML then this should look pretty
straightforward we can see that the
basic screen is just a constraint layout
with attributes are setting things like
its width and height and included in the
constraint layout is a textview with a
text set to hullo will now this can look
a bit complicated if you haven't seen
XML before, I'll switch back over here to
design view and when I do that you can
see this component tree over to the left
and that pretty much echoes what we saw
in the XML view at the top is our
activity underscore main layer the
constraint layout and contained within
the constraint layout is the textview
and when I'm clicking all those things
on the screen it gets highlighted in the
componentry here but it also gets
highlighted on the layout and if I click
something on the layout it gets
highlighted in the constraint layers as
well so either way will work there's
also a load of attributes for the things
we've selected over to the far right
over here. Now if I select the text view
which I've got selected you can see its
text property over here set to hello
world I can change it here so I could
put I was there or I was here would
probably be more appropriate and press
enter and you can see that was updated
here but also updated now in the
designer and also in the componentry now
the textview itself expands
automatically as I type more text so I
come back here and at today you can see
it's expanded to fit the text that we've
actually selected. So I've shown you a
way to update the text and we will be
doing that but there are other ways that
make it easier to make your app
available in other languages. Now you
probably wouldn't change it in a real
application by just over typing what
I've done like I did but we'll be
covering that later in the course but
that way will get us going for now now
there is only a selection of properly
showing on the screen at the moment the
ones that tell you'd probably want to
change most often but you can get access
to all the properties by clicking up
these on these double arrows here at the
top then this version of Android studio
defaults to showing the XML attributes
editor when you first run it so what
I've got here is the list that will
rather the attributes that we're
currently defined or have been defined
for us by the template now in previous
versions of Android studio all the
attributes appeared in an alphabetical
list and that makes life much easier
because you can scroll through and check
out any attributes that sound
interesting but with the release of
Android studio 3 that we're using here
that list doesn't appear straight away
instead we've got the attributes that
we've changed even if we change them
without being aware of it so you can see
things here like layout underscore width
and layout height there's also a text attribute
and the constraints as well which you
may not have been aware that you changed.
so this isn't in other words a very
concise view of the attributes being
used at the moment now if you know which
attributes you want to change it's also
very easy to set it here just type it
into the blank row at the bottom down
here so this concise view is really
great is great when you know what you
want to change but isn't very helpful
when you're learning about all this but
fortunately Google have made the
complete list available so you can click
on this cog drop-down up here and select
all attributes table once we do that
this changes to the same view that
earlier versions of Android studio had
and we can scroll right down the list
and see literally all the attributes we
can actually choose which view to use
here getting it more experienced you may
want to use the XML attribute editor
layout view that we had before just use
the same cog menu up here to change back
to that mode if you want to do that.
Now there's all sorts of things that you can
change here as well so let's scroll up
and have a look I can spare this little
arrow next to constraints you can see
that there's quite a lot of them so you
can make that pain wider by dragging its
edge over here dragged it over but if
you can't see the full names or if
you're short of screen space you can
switch off the design or blueprint modes
using the Select design surface but just
above, so you come up here and we can
just select for example design only to
give us a bit more space then move that
over to get a bit of good more concise
list of all the editors
attributes and we can use that button to
also toggle I can go back into is just
the blueprint different one or two as
well and of course we can also display
them both and obviously depending on the
amount of screen real estate we've got
here remaining to me things are rare to
see them all in their large enough size
to work with do each pane in Android
studio has a button that can be used to
shrink it out of the way so that you can
use the full space on your screen to
focus on what you're doing now at the
moment we're designing a layout and we
don't need to see all the files of the
project you'll notice that each separate
pane has a button that looks like a bar
that's just little one up here and I'll
just zoom in so you can see that a
little bit better it's got a little bar
with an arrow pointing left right or
down now clicking up
which order will shrink the pipe in the
direction of the arrow so that also
gives you an indication of where to look
to get it back again so if you can see
that now a zoom in again that's got a
little arrow pointing to the left if I
click on that you can see that paint is
now closed you can see the button to get
the paint back again in this case it's
the project click on that then that
opens it out again, so you can do the
same with the panes that open up along
the bottom of the Android studio window
down here I can click on log cat and
don't worry about what that means at the
moment but this is all about controlling
the individual page and you'll be seeing
that what they all do a little bit later
so at the far right again I can shrink
the pane and if I have a look doing that
up you can see that it's the arrow
pointing down I click on that point it
goes down and I can click my here to
click on log cat and open it again and
incidentally I can just click on the tab
if I wanna open or close it as well so
in other words it toggled so if I open a
block cat again and this time come over
here and click on event log they're both
next to each other, again I can just use
the buttons to shrink them the closing
down as needed, so there's a lot going on
in Android studio and it can look very
confusing but you can try which panes
you see and you can shrink any that
you're not interested in then it's
Liberty lets you focus on the work that
you want to doing so I've closed down
those two bottom panes I'm also going to
shrink the project pane over here again
so we can focus on this layout and I was
looking at the constraints before before
I started opening and closing paints now
these constraints look a bit confusing
let's expand this out a little bit so I
can see a little bit more but those long
names are intended to describe what each
one does so for example the first one
starts with bottom underscore to bottom
of which tells you that it'll be lining
up the bottom of the textview with
something then you can line the bottom
of our texts you up with the bottom of
something else which is what this first
constraint does but you can also line
the bottom of it up with the top of
something so that's there there's a
bottom to top of here for that reason as
well you don't want to line the bottom
of the textview with the top of another
object on the screen you also lie on the
left or right of a widget with the left
or right of another widget to position
things where you need them. Now lining
everything up in here would soon get TD
and there's a much easier way that I'm
gonna show you shortly
we've got a few more controls on the
screen. So you want to come in here
perhaps to check and maybe change a few
things though especially on a slow
computer or if you've only got a small
screen so for now that I don't worry too
much about what these constraints mean
you don't have to remember them all
once you've lined up a few things
they'll make a lot more sense and
they're gonna be coming back to this and
we will be using this lamp you a lot
throughout the course, so you'll get
plenty of practice for now I just wanted
to quickly show you where you'd go to
make changes to the lands for your apps
well that's we're gonna come over here
click on this double arrow again to go
back to the common properties I get some
screen real estate back and if you did
have both the design and blueprint
selected you can select that now and see
that it'll fit a little bit better.
Now over to the left of those buttons is one
that you can use to toggle the layered
into landscape let's just little button
here so we can click on that and that's
great for checking how things or look
when the device is rotated so I can
click on that and you can see that it's
moved the screen to landscape mode there
we'll be coming back to this layout
editor in the next video the other thing
that I wanted to show you though is the
project pane this is where you choose
which files you want to work on over the
project pane again and I might just grab
a little bit of screen real estate back
and the more also set this back to
portrait but over here in the project
pane I can expand app and expand Java as
I've done here and finally our package
shows up in this case Academy don't
learn programming dot HelloWorld and we
can then see the Kotlin files now under
res there's a layout folder we have a
look at that res layout and that's where
our layouts are stored so basically in
here are all the files that are
associated with the project and they'll
make a lot more sense as we go through
the course but the clever thing is that
Android studio is created in all this
forests saving a lot of time. Now the
common file main activity is one here
I've got selected that's got the card
that Android studio generated for us I went
through this briefly in the video and
templates that's his fault here if we
open it up now there's not much in this
one because we chose an empty activity
template but you can see that's aligned
here is where it uses the activity
underscore main layer
it's code along 10 so that's one way
that the layout files are used to create
the display for our apps so Android
studio has created the basic code for
our app with a layout to define the
screen and the code to display it when
we run the app that's part of the beauty
of Android studio it does a lot of this
work for us saving us a lot of time when
we were creating our applications so
that was a very quick tour of Android
studio and we will be looking at it in
much greater detail as we go through
this course, but before you can do much
experimenting though you need to be able
to run your app to see how the things
we're trying out really behave. So in the
next video we're going to be running
this app in an emulator and I'll be
showing you also how to set up the
emulator as well, then in the video after
that one I'm going to show you how it
runs on a physical Android device so
let's move on now to the next video.