In the previous lesson, you added a Linear Layout to your design surface. We'll now add two buttons to this layout.
Go back to the palette. In earlier versions of Android Studio, click on the Widgets category and locate the Button item. In later versions, there is a Buttons category. Click on this and you'll see a Button item. Drag two of these onto your LinearLayout.
If you don't get this right, and have to undo, you can drag widgets onto the Component Tree instead:
You can even rearrange your widgets in the Component Tree. In the image below we've put button 6 before button 5:
With the top button highlighted, drag down to below the bottom button:
Your blueprint area should now look like this:
Select the first button. In the properties area on the right, locate the text property and enter London Bridge: (You'll see error warnings about this. We'll fix them in the next lesson.)
(The name of your button will probably not be button5.)
Now select the second button and change the text property to Tower Bridge. Your blueprint will then look like this:
Almost done, now.
You can change the background colour of the ConstraintLayout to something other than white.
Go back to design view by clicking the icon in the toolbar in earlier versions of Android Studio:
In later versions, there is a menu instead. Select Design from the menu instead of Blueprint:
In the Component Tree, click on the ConstraintLayout item to select it:
Now look at the properties area on the right. If you have an earlier version of Android Studio, click on the link at the bottom that says View all properties:
For later versions, click to expand the All Attributes item:
You'll then see a fuller list of properties.
Locate the Background property and click just to the right of the word Background, where the white box is in the image below:
Click on the grey square to bring up a dialogue box. Select Color from the left:
Select a colour from the list and click OK. We've chosen holo_blue_dark.
Try it out now. Run your app and see what it looks like. You should see something like this:
Rotate your device and you'll see that the buttons in the layout expand to fill the space:
However, if you're using a real device, your app will probably crash on rotation. You'll see why, and how to fix it, later in the course, when we move on to Activities.
In the next lesson, you'll learn about the XML file. You'll also learn how to add XML strings. This is quite easy!