etsy / AndroidStaggeredGrid

An Android staggered grid view which supports multiple columns with rows of varying sizes.
https://github.com/etsy/AndroidStaggeredGrid
4.76k stars 1.13k forks source link

Add support for multi-column items #68

Open dlew opened 10 years ago

dlew commented 10 years ago

I would like to see support for multi-column items. I wanted to open this topic up to discussion because I understand it would be a large change.

For my particular use-case I mostly want to implement some full-width rows in between the staggered columns (think section headers). You can sort of get this effect by claiming the header rows are of type ITEM_VIEW_TYPE_HEADER_OR_FOOTER but of course that's a hack right now and comes with a host of problems.

The general solution would be supporting multi-column items. Alternatively, a more specific solution (for me) would be to support a section header of sorts (full rows), implement similarly to header/footer rows but the code adjusts for them being in the middle.

I'd be willing to work on it myself and enter it through a pull request, but I wanted to gather thoughts first. Does this go outside the scope of the library, or is it something worth adding? And if it's worth adding, do you have any tips for how to get started?

denizmveli commented 10 years ago

This would be great to add.

My thought is that it would work with each item defining it's column span. Or maybe a more simple first step would be an item that spans all columns.

My first question would be how are we going to have the item tell the grid of it's span? Googles unfinished SGV uses LayoutParams which I think is a mess.

You could have the staggered grid expect a new type of adapter that extends ListAdapter but implements something like getColumnSpan(int position). However I do like that the StaggeredGridView currently works with just a regular old ListAdapter, so I wouldn't want this to be a requirement (it would have to work with both).

Open to other suggestions and ideas.

dlew commented 10 years ago

The simple first step is all I want at this point, so I'm fine if with that.

StickyListHeaders allows one to use a normal ListAdapter by making their add an interface (StickyListHeadersAdapter) that extends its capabilities - that's one way to avoid forcing someone to extend a special Adapter.

klassm commented 10 years ago

Hi, is there any progress to this issue? I'd like to have section headers as well :-) Matthias

dlew commented 10 years ago

We met up in NYC randomly and talked about it but I don't think either of us have started on it seriously.

I guess it'd be good to figure out scope first. Are we just going to focus on making a full-scale header work, or will it be the full thing where you can span N columns instead?

klassm commented 10 years ago

Hi, if you'd ask me I'd start with a full-scale header view. There's much less complexity in it and, later on, you can extend that to spanning n-columns. Matthias