DevAhamed / MultiViewAdapter

Easily create complex recyclerview adapters in android
https://devahamed.github.io/MultiViewAdapter
Apache License 2.0
818 stars 148 forks source link

How to use another LayoutManager for sections? #99

Open JGeraldoLima opened 5 years ago

JGeraldoLima commented 5 years ago

I currently have an app that has a custom layout for the headers, and I need to use SpannedGridLayoutManager to replicate the Instagram Search Page behavior: 1x1 size for picutre items, 2x2 for video ones.

How can I achieve that?

Here is a print of how the screen is looking like:

image

In the header layout, there is no space under the green date badge, it is height fixed by the SpannedGridLayoutManager. I've already tried very hard to change this height in the viewHolder implementation, but no success. When I use GridLayoutManager, as in the sample, works fine, but the views are not organized:

photo5131993973622155278

JGeraldoLima commented 5 years ago

I've already tried to use setSpanCount for the section objetcs, but nothing happens. Also, tried to override getSpanSize, but this does not make a difference too :/

DevAhamed commented 5 years ago

Hi,

GridLayoutManager supports only the column count (span) and doesn't consider the row count. Even StaggeredGridLayoutManager will not help in this case. You need to build your own layout manager. You can take look here for some inspiration - https://lucasr.org/2014/07/31/the-new-twowayview/

As far as the library is concerned, span concept is based upon the default layout managers. But if you create/use a custom layout manager, you can extend the library classes and use it.

JGeraldoLima commented 5 years ago

Actually, my question was: can I, somehow, use a LayoutManager for sections and a different one for ListSections? If so, that would solve my problem, I could use LinearLayoutManager or GridLayoutManager for sections and SpannedGridLayoutManager for section items!

DevAhamed commented 5 years ago

Thanks for clarifying.

LayoutManagers are set to the recyclerview. So unfortunately, this library doesn't support the use case of multiple layout managers.

JGeraldoLima commented 5 years ago

Oh, that's a shame :/

But thank you very much anyway, that's a great library!