Advertisement
English transcript
Whoa, that was a tough concept, but you handled it really well.
This unlocks the ability to build some really awesome layouts in Android
because almost all screens contain some type of nested layouts,
which Correll was actually mentioning earlier in the Google Play app.
After all of that prep work, now we're ready to go back into
Android Studio land to implement the changes for an improved quantity picker.
In case you're wondering, Katherine, what if I'm trying to build a layout and
I don't have three options of XML layouts
magically appear before me that I have to choose from.
Well, that's a fair question.
So far we've practiced being able to read XML and
draw a view hierarchy diagram.
We've also practiced reading XML layouts and
drawing a sketch of what the screen would look like.
But now it's time to practice seeing a design of what we want to build and
being able to write the XML from it.
I do realize that I gave you the solution XML in the previous quiz.
I was somewhat paying attention, but I don't want you to look at that solution.
I want you to practice the skill of seeing a screenshot or
a mock of what you want to build and then being able to write the XML for it.
Normally, we would start with the desired screenshot
of what we want to build.
You can get this from a designer that's working on your team who's
designing the app for you.
Or if you're working without a designer,
you could also sketch this out on your own.
Then you would imagine how to break this down into views and ViewGroups.
You can mark it up and then try to draw out the view hierarchy diagram for
the relationship between the children and the parent views.
After you finish this diagram, you can start writing out the skeleton for
what the XML layout code would look like.
I'll leave these parts as an exercise for you.
You'll make your changes in the activity_main.xml layout file.
Aside from writing your XML here and
seeing a preview of it, you can also click on the design pane here.
This is Design tab as opposed to the Text tab.
The Design pane allows you to drag and drop views onto the device.
You can also see the component tree in the top right corner here.
This is, essentially, a tree of all the views in your hierarchy.
Currently we have vertical LinearLayout, that's the parent view, and
all these children views inside of it.
If you had nested ViewGroups, they would also show up here.
Now go ahead and build this layout in Android Studio.
After you've selected and positioned the views, remember to style them so
it looks like this.
The style of the views is mostly the same,
except note that there's eight dp of space in-between the minus button and
the two and in-between the two and the plus button.
As mentioned earlier, avoid looking at the code and
try implementing it yourself.
When you're done, check this box to continue.
This unlocks the ability to build some really awesome layouts in Android
because almost all screens contain some type of nested layouts,
which Correll was actually mentioning earlier in the Google Play app.
After all of that prep work, now we're ready to go back into
Android Studio land to implement the changes for an improved quantity picker.
In case you're wondering, Katherine, what if I'm trying to build a layout and
I don't have three options of XML layouts
magically appear before me that I have to choose from.
Well, that's a fair question.
So far we've practiced being able to read XML and
draw a view hierarchy diagram.
We've also practiced reading XML layouts and
drawing a sketch of what the screen would look like.
But now it's time to practice seeing a design of what we want to build and
being able to write the XML from it.
I do realize that I gave you the solution XML in the previous quiz.
I was somewhat paying attention, but I don't want you to look at that solution.
I want you to practice the skill of seeing a screenshot or
a mock of what you want to build and then being able to write the XML for it.
Normally, we would start with the desired screenshot
of what we want to build.
You can get this from a designer that's working on your team who's
designing the app for you.
Or if you're working without a designer,
you could also sketch this out on your own.
Then you would imagine how to break this down into views and ViewGroups.
You can mark it up and then try to draw out the view hierarchy diagram for
the relationship between the children and the parent views.
After you finish this diagram, you can start writing out the skeleton for
what the XML layout code would look like.
I'll leave these parts as an exercise for you.
You'll make your changes in the activity_main.xml layout file.
Aside from writing your XML here and
seeing a preview of it, you can also click on the design pane here.
This is Design tab as opposed to the Text tab.
The Design pane allows you to drag and drop views onto the device.
You can also see the component tree in the top right corner here.
This is, essentially, a tree of all the views in your hierarchy.
Currently we have vertical LinearLayout, that's the parent view, and
all these children views inside of it.
If you had nested ViewGroups, they would also show up here.
Now go ahead and build this layout in Android Studio.
After you've selected and positioned the views, remember to style them so
it looks like this.
The style of the views is mostly the same,
except note that there's eight dp of space in-between the minus button and
the two and in-between the two and the plus button.
As mentioned earlier, avoid looking at the code and
try implementing it yourself.
When you're done, check this box to continue.