Skip to content
This repository has been archived by the owner on Jan 2, 2021. It is now read-only.

How to use another LayoutManager for sections? #99

Open
JGeraldoLima opened this issue Aug 28, 2019 · 5 comments
Open

How to use another LayoutManager for sections? #99

JGeraldoLima opened this issue Aug 28, 2019 · 5 comments

Comments

@JGeraldoLima
Copy link

JGeraldoLima commented Aug 28, 2019

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 JGeraldoLima changed the title How to use qanother LayoutManager for sections? How to use another LayoutManager for sections? Aug 28, 2019
@JGeraldoLima
Copy link
Author

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
Copy link
Owner

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
Copy link
Author

JGeraldoLima commented Aug 29, 2019

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
Copy link
Owner

Thanks for clarifying.

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

@JGeraldoLima
Copy link
Author

Oh, that's a shame :/

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants