3

I want to add row separators in GridView. Basically I'm making a shelf app in which shelf will look like this:

enter image description here

so number of columns can vary with device resolution and also when orientation is changed. How do I achieve this? any tricks ?

I have looked at Shelves by Romain Guy. But he has some different strategy because there is no need of row separator.

Nayanesh Gupte
  • 2,735
  • 25
  • 37
  • if you look at that code you will understand that he is adding row separator to each cell where as if you look at my design it is not possible to break that image and add it to each cell. I need one complete image for whole row. – Nayanesh Gupte Mar 11 '13 at 06:01
  • did u get any solution for that? Actually I have also the same problem.Please help – mainu Feb 20 '14 at 07:02
  • you can use ListView with multiple items in one row and then can write onClickListener for items in a row. That's what I did as a workaround. – Nayanesh Gupte Feb 23 '14 at 13:23

1 Answers1

0

try this project from google code and browse view the source code:

https://code.google.com/p/shelves/source/browse/#svn%2Ftrunk

project home page in google code:

https://code.google.com/p/shelves/

and it's already discussed in stack overflow belown post:

background scrolling with item in gridview

Community
  • 1
  • 1
Dinesh
  • 6,500
  • 10
  • 42
  • 77
  • check my comment above – Nayanesh Gupte Mar 11 '13 at 06:02
  • @NayAneshGupte you need separator or row background image of gridview? – Dinesh Mar 11 '13 at 06:04
  • I want something similar to list divider but for GridView i.e. for complete row and not for each cell of a GridView . – Nayanesh Gupte Mar 11 '13 at 06:06
  • @NayAneshGupte can u saw this post http://stackoverflow.com/questions/6734635/background-scrolling-with-item-in-gridview/9757501#9757501 – Dinesh Mar 11 '13 at 06:07
  • i tried it. Funny thing is even if you remove Rect source = new Rect(0, mShelfHeight - top, mShelfWidth, mShelfHeight); Rect dest = new Rect(x, 0, x + mShelfWidth, top ); canvas.drawBitmap(background, source, dest, null); these lines it doesn't affect view. – Nayanesh Gupte Mar 11 '13 at 06:12
  • @NayAneshGupte just post ur code will be check it ok! – Dinesh Mar 11 '13 at 06:26
  • @Dinesh If we set background image layout is broken when scrolling the grid!! But we can scroll to horizontal to avoid this problem http://stackoverflow.com/questions/11174954/how-to-implement-efficiently-a-gridview-layout – LOG_TAG Mar 13 '13 at 06:16
  • @Dinesh, NayAneshGupte can you please share how to use that shelves library for designing the book shelves.. I'm failed to reverse engineer the shelves gridview code! – LOG_TAG Mar 13 '13 at 06:19
  • @Subra Romain Guy's shelves is an open source you can look at it. Also I looked at the solution given in link u specified. And thats the only option I can think of for time being i.e. List view with divider instead of GridView. But managing it is really head ache as compared to simplicity of Grid view. – Nayanesh Gupte Mar 18 '13 at 03:55
  • I also tried above solution & I'm able to draw to separator between rows in GridView, however when I scroll the gridView, only item items get scrolled not the separator.How to scroll items with separator like listView.? – sachin003 Apr 03 '13 at 12:27