Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GridView VS GridLayout in Android Apps

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.

like image 685
Lakshmi Sreekanth Chitla Avatar asked Jul 03 '12 08:07

Lakshmi Sreekanth Chitla


People also ask

What is the difference between GridLayout and GridView in Android?

Let us not get confused with GridView and GridLayout to be the same. GridView simply gives us a two-dimensional view to display the items on the screen, under ViewGroup. On the other hand, GridLayout is a layout manager that arranges the views in a grid.

Is GridView deprecated in Android?

Both GridView and GridLayout are safe for use in production code. They are obsolete, and I would not recommend that anyone use them, but they are safe. You are contradicting yourself. First you say GridView and GridLayout are not deprecated, then you say they are both obsolete, but safe.

What is the difference between a Textview and a GridView?

The only difference is that GridView is used to display grid of View objects. The view objects can be a Text view, an Image view or a view group which has both an image and some text. Best example for this view is phone gallery which shows images in a grid.

What is difference between GridView and RecyclerView?

In GridView it is recommended to use the ViewHolder but it is not compulsion but in RecyclerView it is mandatory to use ViewHolder that is the main difference between RecyclerView and GridView.


1 Answers

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.

like image 86
Benito Bertoli Avatar answered Oct 05 '22 19:10

Benito Bertoli