This will be expensive to destroy and inflate fully new layouts for every item, but can be done.
The card stack is a recyclerview, and you can extend ListAdapter<X, Y> for your CardStackAdapter implementation to handle this. You will need to determine the layout type based on position, and then build the appropriate ViewHolder:
override fun getItemViewType(position: Int): Int {
return someCustomLogicToDeterminLayoutResourceByPosition(position)
}
Then in onCreateViewHolder you'll need to build the appropriate ViewHolder for the layout type. This will likely require a base class for your ViewHolders, and custom ViewHolders per type of item.
I would recommend finding a way to NOT have unique layouts per card if you have a large number of cards in your stack, as it will be expensive. But it is possible.
This will be expensive to destroy and inflate fully new layouts for every item, but can be done.
The card stack is a recyclerview, and you can extend
ListAdapter<X, Y>
for yourCardStackAdapter
implementation to handle this. You will need to determine the layout type based on position, and then build the appropriate ViewHolder:Then in
onCreateViewHolder
you'll need to build the appropriate ViewHolder for the layout type. This will likely require a base class for your ViewHolders, and custom ViewHolders per type of item.I would recommend finding a way to NOT have unique layouts per card if you have a large number of cards in your stack, as it will be expensive. But it is possible.