282 CHAPTER 8: Android UI Design: Using Advanced ViewGroup Layout Containers
Next, we are going to learn how to span multiple columns, by adding an
underneath the current Edit Galaxy Info UI design. We will do this so that users can reference their local
Earth time, while they are utilizing the rest this UI design to update their Galaxy object data fields.
Combining GridLayout Cells: Using a Span
Let’s add the
area itself. To do this, add a new line of space after the parent
to wrap_content, which is what you normally use for an AnalogClock. Since we are going to put
the AnalogClock widget (object) at the top of the design, we’ll use a row and column index of 1,
a columnSpan of 2 (columns), and a CENTER layout_gravity parameter using the following XML
markup, which is also shown in place at the top of your GridLayout in Figure 8-15:
<AnalogClock android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_row="0"
android:layout_column="0"
android:layout_columnSpan="2"
android:layout_gravity="center_horizontal" />
Figure 8-15. Add an AnalogClock widget to the GridLayout, adjust EditText and Button widget index parameters