Android - Gridview or listview?
Asked Answered
P

4

24

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.

Proprioceptor answered 31/3, 2011 at 6:12 Comment(2)
It think, that is a ListView with background image for each item.Proconsulate
@Muddassir Thanx for the quick response, as i told earlier, i think its a listview and each row contains 3 books and each row is having background image. And as such its listview we can set separator as well.Proprioceptor
F
11

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.

Flatting answered 31/3, 2011 at 21:16 Comment(1)
Sorry for the late reply. Thanx for the support. I have downloaded the code and try to review it. But the code is really very tough to understand. Instead of it, if you have any suggestion then please. I just want to load the 5-6 books per row.Proprioceptor
M
2

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?

Millymilman answered 31/3, 2011 at 6:27 Comment(0)
S
2

With a ListView, each row is counted as an element, so there will be extra work in logic that keeps each item within the row separate. I would suggest you use a gridview. For each grid element, keep an empty shelf space (for one book) as the background image. This image will include the shelf-base. So there is no need for additional rows. The image should look like this:

Grid Element Background

Skidmore answered 31/3, 2011 at 6:36 Comment(0)
S
0

I would instead suggest to have grid view and view flipper if the number of books are limited.

View flipper will give a better effect than scrolling.

Student answered 31/3, 2011 at 6:46 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.