GridView VS GridLayout in Android Apps

AndroidGridAndroid GridviewGrid Layout

Android Problem Overview


I have to use a Grid to implement Photo Browser in Android. So, I would like to know the difference between GridView and GridLayout.

So that I shall choose the right one.

Currently I'm using GridView to display the images dynamically.

Android Solutions


Solution 1 - Android

A GridView is a ViewGroup that displays items in two-dimensional scrolling grid. The items in the grid come from the ListAdapter associated with this view.

This is what you'd want to use (keep using). Because a GridView gets its data from a ListAdapter, the only data loaded in memory will be the one displayed on screen. GridViews, much like ListViews reuse and recycle their views for better performance.

Whereas a GridLayout is a layout that places its children in a rectangular grid.

It was introduced in API level 14, and was recently backported in the Support Library. Its main purpose is to solve alignment and performance problems in other layouts. Check out this tutorial if you want to learn more about GridLayout.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionLakshmi Sreekanth ChitlaView Question on Stackoverflow
Solution 1 - AndroidBenito BertoliView Answer on Stackoverflow