Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GridView and GridLayout in android [duplicate]

I trying to add child views for GridView in xml file but it is giving error and it working fine with GridLayout. so I want know .. What is difference b/w GridView and GridLayout in android ?

like image 739
Harry Mad Avatar asked May 09 '26 23:05

Harry Mad


1 Answers

The basic difference is that GridView is a scrollable View like ListView, and GridLayout is a layout. Both look the same but GridView is scrollable

According to the documentation for GridView, the formal definition is the following:

GridView

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.

And the definition for GridLayout, from the same docs

GridLayout

A layout that places its children in a rectangular grid.

The grid is composed of a set of infinitely thin lines that separate the viewing area into cells. Throughout the API, grid lines are referenced by grid indices. A grid with N columns has N + 1 grid indices that run from 0 through N inclusive. Regardless of how GridLayout is configured, grid index 0 is fixed to the leading edge of the container and grid index N is fixed to its trailing edge (after padding is taken into account).


Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!