airbnb / epoxy

Epoxy is an Android library for building complex screens in a RecyclerView
https://goo.gl/eIK82p
Apache License 2.0
8.52k stars 728 forks source link

Set all item's height in Epoxy carousel to match tallest item #1348

Closed roncbird closed 1 year ago

roncbird commented 1 year ago

Hello Airbnb team,

Thank you for providing the awesome Epoxy library. Our team uses it extensively. It works pretty well for most of our use cases, but our product team has recently requested new acceptance criteria that requires us to dynamically adjust the height of each of the items in the carousel to match the height of the tallest item. Unfortunately, we have not been able to come up with a solution for this problem. Here is a video showing the issue.

https://github.com/airbnb/epoxy/assets/6894360/bb3218c3-165b-4413-9ea7-056488110f39

Is there any way with Epoxy carousel to dynamically adjust the height of all the items to match the height of the tallest one?

roncbird commented 1 year ago

Hello Airbnb team, I wanted to follow up regarding the question above, and see if the team has any ideas that will help point me in the right direction. Thank you.

elihart commented 1 year ago

Hi, I think this problem is not specific to epoxy, but can be generalized to all recyclerview usage right? I believe we have also struggled with this, and unfortunately there is not a great solution without measuring out all items ahead of time (since it is impossible to know how tall each item will be before it is shown). I think something that has worked for me somewhat in the past is to set the item height to match parent and the recyclerview to wrap content. The items should all expand to be the same height, as tall as the tallest item; the problem is that it will jump when a new, taller item is shown. I don't know of a better solution then that - one other choice is to set a fixed height for all items and ensure that the content scales to fit the item size, perhaps with resizing text.

roncbird commented 1 year ago

Hi Eli,

Thank you so much for taking your time to respond. I really appreciate it. Yeah, I agree, this is not specific to Epoxy. This is more related to RecyclerViews, but I proposed the question here since Epoxy is essential a recyclerview, and we use Epoxy extensively throughout the app. In fact, I don't think there is any area of our app where we use a traditional RecyclerView. I was hoping maybe someone else had tackled this with Epoxy, and was willing to provide a solution.

I appreciate the ideas. Maybe auto shrinking the text will be an acceptable option to our design/product team. I'll pass that by them. Thanks so much again for your help.