Defining the layout for HelloMoonFragment

Create a new Android XML layout file named fragment_hello_moon.xml. Make its root element a TableLayout.

Use Figure 13.4 to flesh out fragment_hello_moon.xml.

Figure 13.4  Layout diagram for HelloMoon

Layout diagram for HelloMoon

TableLayout works a lot like a LinearLayout. Instead of nesting LinearLayouts, you can arrange widgets using TableRows. TableLayout and TableRow can team up to make it easier to arrange views in neat columns. Here, TableLayout helps arrange your buttons side by side in equally sized columns.

Why is the ImageView not in a TableRow? Children of TableRow act like cells of a table. Your goal here is for the ...

Get Android Programming: The Big Nerd Ranch Guide 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.