From the Designer palette, locate the TableRow entry listed under Layouts and drag and drop an instance directly onto the top of the TableLayout entry in the Component Tree panel.
Now that the TableLayout has been added to the user interface layout, three TableRow instances need to be added as children.
#ANDROID STUDIO TIME PALETTE ANDROID#
The remainder of this chapter, therefore, will be used to work step by step through the design of this user interface using the Android Studio Designer tool. The layout shown in Figure 41-2 is the exact layout that is required for the database example that will be completed in the next chapter. The LinearLayout child view contains three Button children. The TableRows contain two child views, with each child representing the contents of a column cell.
The TableLayout contains three TableRow children representing three rows in the table. The hierarchical tree illustrated in Figure 41-2, however, makes the structure a little easier to understand:Ĭlearly, the layout consists of a parent LinearLayout view with TableLayout and LinearLayout children. In addition, a single cell may be configured to span multiple columns.Ĭonsider the user interface layout shown in Figure 41-1:įrom the visual appearance of the layout, it is difficult to identify the TableLayout structure used to design the interface. Columns may be configured to be shrinkable or stretchable (or both) such that they change in size relative to the parent TableLayout. The number of columns in a table is dictated by the row with the most columns and, by default, the width of each column is defined by the widest cell in that column. Each row within a TableLayout is occupied by a TableRow instance, which, in turn, is divided into cells, with each cell containing a single child view (which may itself be a container with multiple view children). The purpose of the TableLayout container view is to allow user interface elements to be organized on the screen in a table format consisting of rows and columns. As a result, this chapter will focus solely on the user interface design of the database application completed in the next chapter, and in doing so, take some time to introduce the basic concepts of table layouts in Android Studio. It quickly became evident, however, that the best way to implement the user interface was to make use of the Android TableLayout and TableRow views and that this topic area deserved a self-contained chapter. When the work began on the next chapter of this book ( An Android Studio SQLite Database Tutorial) it was originally intended that it would include the steps to design the user interface layout for the database example application. Purchase the fully updated Android Studio Chipmunk Edition of this publication in eBook ($29.99) or Print ($46.99) formatĪndroid Studio Chipmunk Essentials - Java Edition Print and eBook (PDF) editions contain 94 chapters and over 800 pages
You are currently reading the Android Studio 1.x - Android 5 Edition of this book.