Getting Started in Android Development Part 18 - The Basic GridLayout

North Border Software

Home Tutorials Hints & Tips About

Android Apps and Training

Share on Facebook Share on Twitter

Getting Started in Android Development

Part 18 - The Basic GridLayout

In this tutorial we will look at the basic grid layout. The grid layout was introduced in Android 4.0 (Ice Cream Sandwich). It provides a convenient tool for the construction a springboard menu. A springboard menu is a popular method of providing navigation within an app.  It comprises what can be described as images or images with text arranged as tiles on a screen that when touched will provide navigation though the app. Just like the home page of any Android phone or tablet.

The grid layout is generally a child layout. In the example for this tutorial the parent is a linear layout. Quite simply, the four image buttons are placed within the grid layout. Two attribute are added to the GridLayout. These define the row count and column count. The image buttons are then arranged in the order they are placed within the grid layout from top to bottom. Therefore, ib1 is displayed top left, ib2 top right, ib3 bottom left and ib4 bottom right. You will see from the screen shot below that all of the buttons are shown in the top left hand corner.

 Android layout with image buttons and basic gridlayout

To get a more desirable arrangement on the screen we need to use the XML “space” attribute with the image buttons. This is the subject of the next tutorial.

After this tutorial your activity_gridlayout.xml file should look similar to the one below. The, and Android Manifest files are unchanged from the last tutorial.

Download tutorial set 1

© 2015 North Border Software All rights reserved
Privacy and Cookies Terms of Use Disclaimer Copyright
North Border Software Logo