ebarrenechea / header-decor

A couple of sticky header decorations for android's recycler view.
Apache License 2.0
877 stars 158 forks source link

ReverseLayout not working? #70

Open mslobodan opened 7 years ago

mslobodan commented 7 years ago

I set on my LinearLayout manager reverseLayout to true and sticky headers are not working. I want to see headers acting same as reverseLayout is set to false.

Can anybody help with this?

Fedorkz commented 7 years ago

Thats true, reverse layout does not work properly, only stack from end.

oshamahue commented 6 years ago

So I looked at this. I couldn't figure out where to place the headers. In the sample app the list goes like this

-item 0 Header 0 -item 1 -item 2 Header 1 -item 3

And headers stick to top.

In reverse order it makes sense to put the header above the items. Also header should stick to top. But with items has no title we would end up something like this:

Header 1 -item 3 Header0 -item 2 -item 1 -item 0

So 'item 0' looks like under 'Header 0' but it is not. It seems like it because it doesn't have a title. If we have a use case for reverse layout I can start work on it.

assansh commented 5 years ago

@oshamahue One use case could be a chat screen in a messaging application, where date separators should be drawn as sticky headers, and the message list must be drawn in reverse order.

starkej2 commented 5 years ago

So 'item 0' looks like under 'Header 0' but it is not. It seems like it because it doesn't have a title. If we have a use case for reverse layout I can start work on it.

Yeah headers are above the items in the sample app, but item 0 does not have a header (a feature added in #48). But I haven't tried using reverseLayout with this library...

starkej2 commented 5 years ago

One use case could be a chat screen in a messaging application, where date separators should be drawn as sticky headers, and the message list must be drawn in reverse order.

@nassa I actually have that exact same use case. Can't you just reverse the order of your message list?

assansh commented 5 years ago

@nassa I actually have that exact same use case. Can't you just reverse the order of your message list?

You could do that, but then the very first message will be displayed at the top of the list, and the list will grow down. In most of the popular messaging apps the list grows bottom-up, and it is also (arguably) more intuitive, so I wanted to implement it using reverse layout.

Here's my quick-and-dirty implementation, if anyone's interested: https://gist.github.com/nassa/6ebf102c77cd46b0861e232a2df9bf2c

Sorry, I don't have time to implement a proper library-worthy solution right now.

starkej2 commented 5 years ago

If the list is sorted in ascending date order, the oldest items will be at the top and any new messages would get added to the end of the list so it would display bottom up as desired.

On Fri, Sep 28, 2018, 2:55 AM nassa notifications@github.com wrote:

@nassa https://github.com/nassa I actually have that exact same use case. Can't you just reverse the order of your message list?

You could do that, but then the very first message will be displayed at the top of the list, and the list will grow down. In most of the popular messaging apps the list grows bottom-up, and it is also (arguably) more intuitive, so I wanted to implement it using reverse layout.

Here's my quick-and-dirty implementation, if anyone's interested: https://gist.github.com/nassa/6ebf102c77cd46b0861e232a2df9bf2c

Sorry, I don't have time to implement a proper library-worthy solution right now.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/edubarr/header-decor/issues/70#issuecomment-425340454, or mute the thread https://github.com/notifications/unsubscribe-auth/ABQkVAIN5SR-DrYJfLmygjTHa3z_Um9wks5ufcfVgaJpZM4MaSxr .

assansh commented 5 years ago

201809281911071000

Here's what I mean. I want the second layout.

I understand that layout direction has no effect if there are enough messages to fill the entire screen.

starkej2 commented 5 years ago

Yeah my app has that same bottom up layout with headers and I'm not having the same issue.

On Fri, Sep 28, 2018, 9:12 AM nassa notifications@github.com wrote:

[image: 201809281911071000] https://user-images.githubusercontent.com/4612367/46210357-54aa9480-c352-11e8-9381-250e291663c0.jpg

Here's what I mean. I want the second layout.

I understand that layout direction has no effect if there are enough messages to fill the entire screen.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/edubarr/header-decor/issues/70#issuecomment-425431256, or mute the thread https://github.com/notifications/unsubscribe-auth/ABQkVLbH-RykX5e3g48PCctOLaLZeI96ks5ufiBVgaJpZM4MaSxr .