Charles Galvez Charles Galvez - 5 months ago 41
Android Question

Recyclerview 2 Different Layouts

So I'm making an application that has 2 different layouts inside a only one RecyclerView.

I can do that, but my problem is,

I want to set the size of "A"(Please look at the pic below) to take 70% of screen size.

And "B" to take 30% of the screen.

I Know how to work with weight_sum/layout_weight but I can't think of anything

that will work for this.

enter image description here


You can get screen height in that case and pass it to your recyclerview adapter.

Use getItemViewType() for two different layouts.

and in OnCreateViewHolder() while creating view set heights to view as per your requirements. It will work.