ethanhua / Skeleton

A library provides an easy way to show skeleton loading view like Facebook and Alipay
3.67k stars 454 forks source link

RecyclerView use two different layouts? #38

Open lpbas opened 4 years ago

lpbas commented 4 years ago

First of all I would like to thank you fort this amazing library!

In the app I'm building, my layout has a different first item in the RecyclerView, a "header" or "promoted" first item, and the rest of them are a second layout. Is there a way to get Skeleton to mimic this layout?

Imagine the layout where it's a vertical list of articles, and the first article is double the height of the rest of them, and some elements moved around, like the title.

Thank you!

ethanhua commented 4 years ago

@L4grange yes, you can use loadArrayOfLayouts api instead of load

mbt925 commented 4 years ago

Why I can't find such a method?

InsaneDoggo commented 4 years ago

I use workaround: create another viewType special for loader + two layouts, first - as wrapper/container for Skeleton.bind(View) approach, second - skeleton layout itself. In adapter's onCreateViewHolder method you need to inflate wrapper layout (as for ussual item), then initialize it via Skeleton.bind.

Note: It's important to initialize skeleton in adapter's onCreateViewHolder, cuz it's called once per viewholder's life, while onBindViewHolder - might be called multiple times (recycling mechanism).

avinashbanswada commented 4 years ago

Can you explain in detail please