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.

Nightfirecat
  • 11,432
  • 6
  • 35
  • 51
Paresh Mayani
  • 127,700
  • 71
  • 241
  • 295
  • 2
    It think, that is a ListView with background image for each item. – Mudassir Mar 31 '11 at 06:20
  • @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. – Paresh Mayani Mar 31 '11 at 06:23

4 Answers4

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.

balazsbalazs
  • 4,071
  • 1
  • 24
  • 29
  • 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. – Paresh Mayani Apr 28 '11 at 10:34
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?

Nanne
  • 64,065
  • 16
  • 119
  • 163
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

Rajath
  • 11,787
  • 7
  • 48
  • 62
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.

Jana
  • 2,890
  • 5
  • 35
  • 45