The default layout in a Blank App’s GUI is a RelativeLayout
. Here, you’ll change that to a GridLayout
. First, right click the TextView
in the Outline window, then select Delete to remove it from the GUI. Next, right click the RelativeLayout
in the Outline window and select Change Layout.... In the Change Layout dialog, select GridLayout
and click OK. The IDE changes the layout and sets its Id to GridLayout1
. We changed this to gridLayout
using the Id field in the Properties window. By default, the GridLayout
’s Orientation property is set to horizontal, indicating that its contents will be laid out row-by-row.
Recall that the GUI in Fig. 3.3 consists of two columns. To specify this, select gridLayout
in the Outline window, then change its Column Count property to 2
(in the Properties window’s GridLayout group). By default, there are no margins—spaces that separate views—around a GridLayout
’s cells. Set the GridLayout
’s Use Default Margins property to true
to indicate that the GridLayout
should place margins around its cells. By default, the GridLayout
uses the recommended gap between views (8dp
), as specified at