-
Notifications
You must be signed in to change notification settings - Fork 156
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding Headers (Create Sections) #9
Comments
You can't really add an option for sections to this library as it is only a layout manager, not an adapter. You could make two separate ViewHolders (one for the header, the other for the items) and manage the difference in item positions yourself, or you could use this awesome library. ;) |
But then again, the LayoutManager should handle the different cases of laying out the different itemTypes, isn't it ? I only need to know how to handle case where I want to put an item in a single row, like a header, and put the rest of images below them in a new row and so on. BTW, this library uses spanCount so it is utilizing the LayoutManager (Which is GridLayoutManager or LinearLayoutManager), which has same size for items. |
Anyone here care to help on this issue ? I don't mind doing it myself of course, but I would love for some direction. |
All that the You shouldn't need to write your own layout manager for what you want to do here, you can just use an adapter with an overriden |
On second thought, if you have a fixed amount of sections it might be better to put the headers inbetween |
But then again, this library isn't utilize GridLayoutManager or StaggeredGridLayoutManager, it has its own GreedoLayoutManager that is arranging items in RecyclerView so how can I use the getItemViewType() correctly without spanning like in GridLayoutManager or StaggeredGridLayoutManager ? I need to distinguish between 'real' image and an item that takes the whole screen width in single row. As for the nested RecyclerViews, it won't be a good solution because I need to use drag-select acroos all items, and in nested recyclerview it will be always per recyclerview and not all of them. Any other idea on how to achieve a single item in a row with this library ? |
Oh I see the problem now, sorry about that :P |
Oh thank you very much ! If you will work this out for me, I would really appreciate it 👍 |
Did you manage to get a solution for this ? Trying to set the view's width to match parent based on viewType didn't help much either, it still not a single item in a single row. |
@eshkoliGilad How about returning big aspect ratio for needed positions? Didn't test, but in my app i have recyclerView (with greedoLM) with images as items, and some wide images with smaller heights (1200x430, aspectRatio ≈ 2.79) have full width. |
I'll try that, thanks. |
Hey guys, nice discussion. Wanted to add a few words. In #14 I've implemented header support which is something we needed internally. Adding section support is probably pushing it in terms of what this library was meant to be though. Feel free to fork and add the functionality. #14 is a start that can point you in the right direction. A
I don't know the scope of your project, but what @alashow suggested, though a hack, may suffice. Just make sure to return the correct aspect ratio to get a fixed height across all the different device widths. The idea would look something like this: // There are in px
int sectionHeight = 200;
int sectionWidth = deviceWidth;
// ...
@Override
public double aspectRatioForIndex(int index) {
// ...
if (isSection) return sectionWidth / (double) sectionHeight;
// ...
} Hope that helps! |
Thanks @JVillella. I've tried it and it does work only for the first item in the list if it is a header, meaning it will take the whole row with a single item, but it does not work if ,lets say, I've a header item in position 3 or 4 when there is already an item in a row before it in the current row, it will just take the rest of the line but also with the item before his position, meaning it will not break into a new line. I need something like that, just for reference: Currently I'm using multiple FlowLayout for assigning the photos one next to the other, but wanted RecyclerView support so this library should be great for my needs. I also need to use this functionality: https://github.com/afollestad/drag-select-recyclerview in order to drag and select photos for deletion so I do need only one RecyclerView, o/w I'd just could have build many RecyclerViews needed. Any idea how to 'force' the RecyclerView to break a new line before an item with the RecyclerView's width is laying out ? |
Sorry for the repeating nagging but it is quite urgent for me. |
First of all, amazing work, seriously.
My question is how to add headers and divide the images to sections ?
I need to sort the images by date and then show them section after section.
If this is not a feature that should be written at all, do you have any idea on how to solve this ?
I trully need this kind of thing.
If I'll add a photo that will take the entire screen width, will it work ?
Edit: I must use the same RecyclerView for them all for Drag and Select for deletion (I Use DragSelectRecyclerView) so I can't have more RecyclerViews like I wanted.
The text was updated successfully, but these errors were encountered: