Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android - Gridview or listview?

Tags:

How do i create this kind of views in my application? (The screenshot is actually of an android application available in android market).

enter image description here

I am confused as i assume that we can create the same kind of layout either by using Gridview or by using ListView.

Problems:

  • In Gridview, can we give separator between two rows? can we give background to each row in gridview?
  • In Listview, i think we can customize the listview with 3 books in a row with background, and we can give a separator as well.

From your expert side, please suggest me a possible solution to design and create the same kind of layouts for the android application.

like image 217
Paresh Mayani Avatar asked Mar 31 '11 06:03

Paresh Mayani


People also ask

What is difference between ListView and GridView in Android?

The main difference between ListView and GridView is how it lays out its child. With ListView you are laying your children one by one either vertically or horizontally only. With GridView, its a combination of both. It lays its children horizontally first.

What is the use of GridView in Android?

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

What is difference between list view and GridView?

List view provides users a format that follows their natural reading patterns like the F-shaped pattern, while grid view is a little more interruptive, making it best suited for visual content. You can jump from one image to the next without worrying about order or continuity.

What is GridView layout in Android?

Android GridView shows items in two-dimensional scrolling grid (rows & columns) and the grid items are not necessarily predetermined but they automatically inserted to the layout using a ListAdapter.


2 Answers

Look at the code of Shelves, written by Romain Guy (one of the ListView's creator).

He used a GridView:

  • no separator

  • background is a bitmap drawable

    < bitmap xmlns:android="http://schemas.android.com/apk/res/android" android:src="@drawable/shelf_panel" android:tileMode="repeat" />

  • background image is like this:

The code is worth a look because it contains other interesting solutions, too.

like image 166
balazsbalazs Avatar answered Nov 12 '22 18:11

balazsbalazs


Stated problems:
In Gridview, can we give separator between two rows? can we give background to each row in gridview?

Well, you can always make up a separator by adding something on the bottom of your view. Make it so that it 'connects' on the sides, and you won't know the difference. It will cost you an extra view per grid-item, so probably not the best option.

In Listview, i think we can customize the listview with 3 books in a row with background, and we can give a separator as well.

Eeuhm, yes, although I don't see what the problem is?

like image 22
Nanne Avatar answered Nov 12 '22 19:11

Nanne