3.4 Building the GUI
In this section, we’ll show the precise steps for building the Tip Calculator’s GUI, including how to customize the Material theme’s primary and accent colors.
3.4.1 GridLayout
Introduction
This app uses a GridLayout
(package android.widget
) to arrange views into four rows and two columns, each indexed from 0 like the elements in an array. You can specify a Grid-Layout
’s number of rows and columns in the Properties window. Each cell can be empty or can hold one or more views, including layouts containing other views. A row’s height is determined by the row’s tallest view. Similarly, a column’s width is defined by the column’s widest view. Figure 3.2 shows the Tip Calculator’s GridLayout
labeled by its rows and columns—we ...
Get Android How to Program, 3/e now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.