Creating Grid View

Whats Up Geeks,

In the last tutorial we have seen Creating Relative Layout.

In this tutorial we are going to learn how to create Grid View?

So the question comes how to display items in a two-dimensional scrollable grid.
And the answers id through Grid View.
GridView is a ViewGroup that displays items in a two-dimensional, scrollable grid. The grid items are automatically inserted to the layout using a ListAdapter.


 

For Example:
In open the res/layout/main.xml file and insert the following: 
<?xml version="1.0" encoding="utf-8"?> 
<GridView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/gridview"
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"
    android:columnWidth="90dp"
    android:numColumns="auto_fit"
    android:verticalSpacing="10dp"
    android:horizontalSpacing="10dp"
    android:stretchMode="columnWidth"
    android:gravity="center"
/>


See you guys in the next tutorial on Adding a Text Field.

3 comments: