Changes

Jump to: navigation, search
Creating the GridLayout Instance
== Creating the GridLayout Instance ==
On creation of the new project, Eclipse should have displayed the Graphical Layout tool and pre-loaded the activity_grid_samplefragment_grid_sample.xml file. In the event that this is not the case, simply navigate to GridLayoutSample -> <package name> -> res -> layout in the Package Explorer panel and double click on the activity_grid_layoutfragment_grid_layout.xml file.
With the layout displayed, select the Hello World! Text View object and press the keyboard Delete key to remove it from the layout. Next, right-click on the white layout view background and select Change Layout… from the resulting menu. In the Change Layout dialog, select GridLayout from the New Layout Type: menu and click on OK to change the layout type.
For the purposes of this tutorial, the GridLayout is only required to be large enough to contain accomodate the child views contained therein. As such, the height and width parameters of the view need to be changed from match_parent to wrap_content. To make this change, select the layout, either by clicking on the white background of the user interface canvas, or from within the Outline panel. With the view selected, unfold the Layout Parameters section of the Properties panel and change the Width and Height values to wrap_content as illustrated in Figure 15-1:
<google>ADSDAQBOX_FLOW</google>
[[Image:android_wrap_content.png|Changing the height and width properties of an Android GridLayout instance]]
Finally, switch to the XML view of the layout resource file by clicking on the activity_grid_layoutfragment_grid_layout.xml tab located along the bottom edge of the Graphical Layout panel and edit the XML to remove the padding properties:
<pre>

Navigation menu