When scrolling in a RecyclerView, I want to achieve something like this:

Where the center item is scaled bigger than the other items. I've found a way to scale all the items, or what is called a Carousel Effect. But that is not what I want. I want to scale only the center item, and keep the other items their default size.
this is what I've found on other answers:
override fun onAttachedToRecyclerView(recyclerView: RecyclerView) {
val snapHelper = LinearSnapHelper()
snapHelper.attachToRecyclerView(recyclerView)
recyclerView.addOnScrollListener(object : RecyclerView.OnScrollListener() {
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
val layoutManager = recyclerView.layoutManager!!
val midpoint = layoutManager.width / 2f
val distance = shrinkDistance * midpoint
for (i in 0 until layoutManager.childCount) {
val child = layoutManager.getChildAt(i)!!
val childMidpoint = (layoutManager.getDecoratedRight(child) + layoutManager.getDecoratedLeft(child)) / 2f
val d = Math.min(distance, Math.abs(midpoint - childMidpoint))
val scale = 1 + -shrinkAmount * d / distance
child.scaleX = scale
child.scaleY = scale
}
}
})
}
As I said, this scales all the visible items, where I only want to zoom the center item.
You could give the middle child different scaling.
Calculate the middle child from childCount and use a different scaling for it than the others.