Hire everyone in this tutorial I want to talk to you about that relationship between lay out wait and
lay out with.
So let's create a new and great studio project and here for the application and just type in here lay
out wait where it says lay out what you can specify the company domain package name and the project
location here.
So just click on next.
So here choose a 16 Android 4.1 jellybean as the minimum SDK for phone and tablet and then click Next
choose MTI activity next and here just leave things as default here.
Just click on finish.
So now that the project is created lets actually close this window here.
Let's go to the activity under limited exemption.
So let's start with Twitter on this topic in order to make this area wider.
So as you can see we have the constraint lay out as the default layout of when we actually create our
Android application.
So I don't want this constraint play out because all you want to use the lay out weight here and the
lay out weight is actually only possible in say the linear layout not constrained to lay out or relatively
out.
So let me repeat again we can only use the lay out weight inside the linearly out.
So here just click on inside this componentry section just click on this constraint to lay out and that
person delete you on your keyboard.
So as you can see we try not delete it.
So let's actually click on this text tap it at the bottom.
And here we can just select all these codes here.
Except this line of code that says XML version here in code in UTF 8 just select all these codes and
then personally reach on your keyboard.
And if I go to the Design tab.
Now let's actually write a linearly out here.
So instead is palette section just click on layouts and here let's select this one linearly out.
We're C-card here to select it and put it here.
Inside are actually the screen so we cannot do it right.
So let's go to the next step here and let's actually open a tag and just type in here linearly out.
And then here just put an end in take here.
So let's actually create some space here and now we need to actually provide some attributes for our
linearly out.
So first we need to specify the layout height so the layout height is going to be actually match parent.
So just typing here much underline parent and then we need to specify that lay out.
We actually lay out other line.
So for the lay out 5th again match parent and then we need to specify the orientation so that orientation
is going to be worth the cost.
So that's it.
And let's click on the preview here on the right sidebar here so you can see that we have our Linnea
lay out here.
If I actually go to the Design tab now you can see that we have our linearly elsewhere Tikal here.
So now let's I want to actually drag our linear layout horizontal here.
So let's say this pallet section.
Just click on layouts and select it linearly or horizontally and dragged here into this linearly or
vertical.
So now we have this linearly horizontal inside this linearly Oswestry call.
So let's actually change some properties of this linearly authorities on onto.
So for the layout height Let's actually assign the value of raw content and for the layout which I think
match parent is cute.
So I've got to actually track some mixed views into this linearly as what is on.
So click on this widget see it inside this palette section and select is text view and just dragged
him into this componentry section and put it inside this linearly out horizontally.
Now this linearly at horizontal holds this takes view right.
So just select this text view and because I want to actually touch about to lay out wait in this tutorial
for the actually for the layout we can see that we have our content content and for the are height we
have our content right.
So let's now write another text view into our linearly or horizontally against Celtic estates and just
put it here below.
This takes you there is actually Enceladus linearly outhaul is on.
So now this linearly or horizontal holds two text views right.
We have one text here and we have our second takes here the value of the length of both of these takes
views is actually rap content.
Right.
And these two takes views are inside these linearly or horizontal but now you may ask so why.
Actually this text is not wrapped.
Right.
It is.
It's it is rap content but you can see that the Tick's view here the text is not up.
Why.
Because the pattern to lay out which is actually that is one linearly al-Hadi horizontally.
They'll lay out a of this linearly or horizontal is much parent and match pennance means that the Viets
of these linearly horizontal is going to actually take the entire bit that is actually remained here.
So that means that whatever user interface components that we put here must actually correspond to the
lay out of it.
Right.
Because the linearly add horizontal is going to take the entire week here and our text views are actually
inside linearly or horizontal we can see that these the width of these text views charity related in
a way to take the entire actually Viets of their linearly and horizontal.
So how we can solve this problem.
Oh you want this takes view.
He wants the text to be of this text.
But actually that lay out which of these takes you to be rap content.
Right.
I want to this content to be wrapped.
So just click on this linearly at horizontal and for the layout of the assigned wrapped content.
Now you can see that the text of this text views is actually lapped right.
So that's it.
And now I want to talk about talk about the lay out the weight.
Right.
So now let's actually select this takes few here.
And for the layout we assign the values zero right.
I assign the value zero for the length of each.
And because I assigned the value zero for the level of each.
All you need to assign a value for there actually have to wait so let's actually go go to the properties
here you can see that we have this option that says View all properties.
Just click on it.
Now let's find out.
Wait here we can see that because this is actually inside linearly out this linear horizontal we can
use this outwait.
So for the out weight here of these text.
So I want this takes you to actually take 50 percent of the Viets of the patent right.
So the patent is linearly at horizontal right but it is actually Lappe content.
So I need to change it to match Pallant and let's select the state's view.
So I told you that I want this takes you to take 50 percent of the feet of the parent.
So that is the view for the outfits I assign the value zero.
And for the lay out weight I can't assign the value 50 right.
But now you can see that it is actually taking much more space.
So that's because of the stakes here.
So now let's say like this takes you here.
This second takes you and all you want.
This second takes you to also take 50 percent of the Viets of the parent which is this fun linearly
horizontally so that it does takes you two and four to lay out with assigned values zero.
And for the lay out weight is only value 50.
So here you can see that each of these takes views is taking 50 percent of the lay out weight.
So that's why for the layout of these linearly or horizontal I assigned the value match parents so it
is going to actually take the entire width so that we have enough space for our text views here Enceladus
or linearly out horizontal.
So let's try another linearly or told this actually to direct another text view into our linearly or
horizontally.
So click on these widgets here and just click on takes you here and just drag it and put it BIDU this
takes butu inside is linearly horizontal.
So now we have free takes views right.
So now you want each of these takes views to only take 30 percent of the entire actually linearly out
horizontal.
So in that case again just select all of these takes views here inside this componentry section for
the layout of Viets assign the value zero.
And for the layout rate here here assign the value 50 person enter the general table.
So now these takes views are going to take 30 percent of them patently out which is going to be linearly
or horizontally or if you want to be more exact.
I can actually divide 100 by three.
So let's see how we can do that.
So in order to be more exact here I need to actually imagine just suppose that the entire width of this
linearly or is this linearly horizontal is 100 souq 100 divided by.
So if we have free takes views right 50.
So it is going to be three point three.
So for the lay out weight of all these takes views so going so this componentry section and Ceric all
these takes viewers inside is linearly horizontal.
And for the length weight assigned a value free point free and that person enter on your keyboard.
So now it is more exact.
It is more precise actually.
So now we can see that these takes viewers inside this linearly holds onto are actually taking an equal
vote here.
Right.
So the stakes actually takes only at three point three of these linearly or horizontal.
So this is going to be depth actually the lay out rate but because we assign the value zero for the
lay out and we assign the value free point free it is going to actually take one third of these linearly
out horizontal.
One friend of the beat of this linearly at horizontal and our second takes is actually the same again.
We assign the value zero for the left right.
So that's at the level which is not going to interfere with the lay out weight because all you want
to specify the layout of this text view according to the other takes views here according to them.
And Matt actually did a patently out.
OK so I don't want to lay out the value of the lay out to interfere with that here.
So let's take a look here is actually that this is 0 0.
And for the lay out weight I assigned the value 3.3.
So hopefully that makes sense and hopefully we can actually specify what is the difference between lay
out we and the lay out weight.
You could also use the lay out wait for the lay out height actually.
But here in our case I just prefer to use the lay out with the lay out actually wait.
And I told you the defense that why the rap content actually doesn't work for our specific user interface
components for this for example for this takes view when it is inside linearly or horizontal.
I told you that because the linearly or horizontal is actually match parent did actually rapin capability
of our Takes view is going to be disabled.
Why.
Because our text views are actually inside a linearly or horizontal that it's we lay out which is match
parent.
So we need to also consider that because this text is a child of this linearly or horizontal and this
linear horizontal is the parent of this takes view.
So hopefully that makes sense if you have any questions about these concepts that it has to in this
lesson.
Please post the discussion in the course and then I do my best to answer all of your questions.
Thank you very much for watching and I'll see you in the next story on.