Added in API level 1

GridView


open class GridView : AbsListView
kotlin.Any
   ↳ android.view.View
   ↳ android.view.ViewGroup
   ↳ android.widget.AdapterView<android.widget.ListAdapter>
   ↳ android.widget.AbsListView
   ↳ android.widget.GridView

A view that shows items in two-dimensional scrolling grid. The items in the grid come from the ListAdapter associated with this view.

See the Grid View guide.

Summary

XML attributes
android:columnWidth Specifies the fixed width for each column.
android:gravity Specifies the gravity within each cell.
android:horizontalSpacing Defines the default horizontal spacing between columns.
android:numColumns Defines how many columns to show.
android:stretchMode Defines how columns should stretch to fill the available empty space, if any.
android:verticalSpacing Defines the default vertical spacing between rows.
Inherited XML attributes
Constants
static Int

Creates as many columns as can fit on screen.

static Int

Disables stretching.

static Int

Stretches columns.

static Int

Stretches the spacing between columns.

static Int

Stretches the spacing between columns.

Inherited constants
Public constructors
GridView(context: Context!)

GridView(context: Context!, attrs: AttributeSet!)

GridView(context: Context!, attrs: AttributeSet!, defStyleAttr: Int)

GridView(context: Context!, attrs: AttributeSet!, defStyleAttr: Int, defStyleRes: Int)

Public methods
open CharSequence!

open ListAdapter!

open Int

Return the width of a column in the grid.

open Int

Describes how the child views are horizontally aligned.

open Int

Returns the amount of horizontal spacing currently used between each item in the grid.

open Int

Get the number of columns in the grid.

open Int

Return the requested width of a column in the grid.

open Int

Returns the requested amount of horizontal spacing between each item in the grid.

open Int

open Int

Returns the amount of vertical spacing between each item in the grid.

open Unit

open Boolean
onKeyDown(keyCode: Int, event: KeyEvent!)

open Boolean
onKeyMultiple(keyCode: Int, repeatCount: Int, event: KeyEvent!)

open Boolean
onKeyUp(keyCode: Int, event: KeyEvent!)

open Unit

Sets the data behind this GridView.

open Unit
setColumnWidth(columnWidth: Int)

Set the width of columns in the grid.

open Unit
setGravity(gravity: Int)

Set the gravity for this grid.

open Unit
setHorizontalSpacing(horizontalSpacing: Int)

Set the amount of horizontal (x) spacing to place between each item in the grid.

open Unit
setNumColumns(numColumns: Int)

Set the number of columns in the grid

open Unit

Sets up this AbsListView to use a remote views adapter which connects to a RemoteViewsService through the specified intent.

open Unit
setSelection(position: Int)

Sets the currently selected item

open Unit
setStretchMode(stretchMode: Int)

Control how items are stretched to fill their space.

open Unit
setVerticalSpacing(verticalSpacing: Int)

Set the amount of vertical (y) spacing to place between each item in the grid.

open Unit

Smoothly scroll to the specified adapter position offset.

open Unit

Smoothly scroll to the specified adapter position.

Protected methods
open Unit
attachLayoutAnimationParameters(child: View!, params: ViewGroup.LayoutParams!, index: Int, count: Int)

open Int

open Int

open Int

open Unit

open Unit
onFocusChanged(gainFocus: Boolean, direction: Int, previouslyFocusedRect: Rect?)

open Unit
onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int)

Inherited functions