YouSub
Untitled

en English

Untitled English subtitles

0 downloads · 75 lines · added Dec 12, 2015

Report a problem
What's wrong?
Advertisement

English transcript

I'm going to draw out the different options for you.
For Option A, we have a vertical LinearLayout as the root view.
I'm just going to draw a big old rectangle.
And I'll keep in mind that as I add views to it,
it needs to be added in a vertical column.
The first child is a TextView that says Quantity, and
it's in all caps because it's a header.
So let me draw that in.
Next we have a horizontal LinearLayout.
I'm going to draw it over here and add children horizontally.
The first child of this LinearLayout is a minus button, so
I'm going to draw that here.
The second child of this horizontal LinearLayout is a TextView that
has the text two in it.
The third child is a plus button, so I'm going to add that here.
All these children are added horizontally, and
this whole horizontal LinearLayout is a child within this vertical LinearLayout.
Next, we have a TextView that says Price, and it's in all caps.
It's followed by another TextView that says $10, and
lastly we have a Button that says Order.
Nice, that actually looks like what we want.
But we'll hold off on any judgements, and
we'll keep looking at the other options and sketch them out first.
For Option B,
remember that the view hierarchy diagram was very similar to Option A.
By looking at the XML more closely,
let's see if it actually looks the same on the device.
We're going to start with a horizontal LinearLayout as the root view.
As I add children, I'm going to have to add them horizontally here.
The first child is a TextView that is the quantity header, so
let me draw that in.
Next, we have a nested LinearLayout with orientation vertical.
I'm going to draw that right here so
it comes horizontally after the quantity TextView.
As I add children to this LinearLayout,
I'm going to add them vertically as in a vertical column.
The first child is the minus button.
Let me draw that.
Below that we have a TextView that says two.
And below that we have a plus button.
That finishes this nested LinearLayout.
We also have a price TextView, the $10, and also an Order button.
Taking a step back, this doesn't quite look like what we want.
So I'm going to take a wild guess and say Option B is not the correct answer.
Let's move on to Option C.
Option C had a very different view hierarchy
in that it only had four children under the root parent LinearLayout.
This parent view is a vertical LinearLayout.
That means the children will be added vertically one after the other.
The first child is a horizontal LinearLayout.
That means I have to add the children horizontally, one after the other.
The first child is a TextView that says quantity.
Then I have a minus button, the text that says two, and a plus button.
That also looks funny, but we'll keep going.
After this plus button is the closing tag of the LinearLayout.
So after that, these children are part of the vertical LinearLayout.
So this price TextView needs to go vertically underneath this horizontal
LinearLayout.
The price TextView and the Order button are also part of
the vertical LinearLayout, so they need to go underneath the price.
This is what the layout looks like.
As you can see,
this quantity TextView has been made a child of this horizontal LinearLayout.
So the quantity picker is showing up here but also the quantity header.
This difference in layout is all because
we moved the TextView to have a different parent.
In the screenshot of the desired layout, we have the quantity
header on top of the quantity picker, not beside each other.
So we need to move this quantity TextView to be a child
of this vertical LinearLayout and not a child of this horizontal LinearLayout.
Here are the sketches side by side.
Clearly, Option B is not what we want, and Option C is correct, except for
the fact that quantity and the quantity picker are in the wrong spots.
They should be on top of each other.
That leaves Option A, which does actually build the desired layout.

Need subtitles from another video?