5

I am trying to achive this:

(

First I tried by putting all my recyclerviews (with WRAP_CONTENT) inside a nestedscrollview. That worked, but the performance was awful. Then I tried to set a height for my recyclerviews, that was a lot better (especially the first gridlayout and the horizontal linearlayout loaded very fast), but still had the problem with the dynamic "category" part.

Now I am trying to put all my recyclerviews inside a single recyclerview with different viewtypes. Since that is a pretty big deal (I need to refactor a lot of code because I have diveded every area from the screenshot inside a single fragment and now I need to put all that code inside an adapter) I wanted to ask if I can actually expect any gain from this, because in the end its again a "nestedscrollview" (made by myself, but...). Or if there is some other "best practice" way to achive this layout.

Thank you

Edit: As expected this didnt do the trick neither. When just the two first recyclerviews are added as viewtype it scrolls and loads smoothly. But as as soon as I try to add the category items (below the category), I notice a lag and especially when selecting multiple categories and scrolling fast up, there is noticable lag. I guess I will have to change my layout and move the category selection part inside a separate view, just need to come up with a user friendly solution. But its acutally quite dissapointing that, in my opinion such trivial task, laying out multiple tables, is such a pain in the ass on android.

rimes
  • 761
  • 1
  • 8
  • 25
  • What is the problem? What is the data source for each part? – Sina Jul 27 '20 at 12:09
  • As I wrote there is currently no actual problem. For me it just seems cumbersome to put couple recyclerviews inside one recyclerview (especially when I need to put some logic inside every viewholder). In the end I would have 3 viewtypes inside the root adapter and then inside every viewtype again an adapter with a gridlayout/linearlayout. My question was if I should expect any gain by this approach (compared to a nestedscrollview) or if there is some other way to achive what I want – rimes Jul 27 '20 at 12:49

2 Answers2

2

I didn't manage to get it working with standard android stuff.

Now I am using epoxy from airbnb ,and I have converted all my views from nestedscrollview to the epoxy recyclerview. Its a great library, and airbnb use it too for all their views.

Nevertheless it's sad that the android dev team doesn't address this problem and provide a solution besides the info "don't nest multiple scrollviews(recyclerviews) that scroll into the same direction".

rimes
  • 761
  • 1
  • 8
  • 25
0

You can use Recyclerview in recyclerview.

https://irpdevelop.wordpress.com/2016/02/10/horizontal-recyclerview-inside-a-vertical-recyclerview/

And make sure to use multiple view types.

Ankit Lathiya
  • 199
  • 1
  • 12
  • I am using viewtypes, but my setup is a little bit more complicated than the one in the article :) – rimes Jul 28 '20 at 12:45