The GridView displays the control horizontally and then vertically.
As shown in the preceding figure, let's take a look at the layout file of the GridView.
<?xml version="1.0" encoding="utf-8"?> <GridView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/brainheroall" android:background="#FFeff1ef" android:layout_width="fill_parent" android:layout_height="wrap_content" android:numColumns="auto_fit" android:verticalSpacing="10dp" android:horizontalSpacing="10dp" android:columnWidth="90dp" android:stretchMode="columnWidth" android:gravity="center" />
This shows how to display the GridView. The xml file below shows how to display the content in the GridView.
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_height="wrap_content" android:paddingBottom="4dip" android:layout_width="fill_parent"> <ImageView android:layout_height="wrap_content" android:id="@+id/ItemImage" android:layout_width="wrap_content" android:layout_centerHorizontal="true"> </ImageView> <TextView android:layout_width="wrap_content" android:layout_below="@+id/ItemImage" android:layout_height="wrap_content" android:text="" android:textColor="#FF000000" android:layout_centerHorizontal="true" android:id="@+id/ItemText"> </TextView> </RelativeLayout>