I am trying to achieve a RecyclerView as shown below:

Elements are views of the same type, but with different scales. I tried to call
view.setScaleX(scaleFactor); view.setScaleY(scaleFactor);
In the OnBindViewHolder adapter method, as well as in ItemDecorator, but each time the behavior of the list was unexpected. What is the best approach to achieving it? It may be with some other control, like a PagerAdapter or another.
UPD: the scaling factor depends on the position of the element in the adapter and should not change when scrolling.
UPD2: Here is the code I tried in OnBoundViewHolder:
int childCount = recyclerView.getChildCount(); View view = holder.getView(); if (position == childCount){ view.setScaleX(1f); view.setScaleY(1f); } else if (position == childCount - 1){ view.setScaleX(0.8f); view.setScaleY(0.8f); } else if (position == childCount - 2){ view.setScaleX(0.6f); view.setScaleY(0.6f); } else { view.setScaleX(0.4f); view.setScaleY(0.4f); }
And here is the result (and it changes when scrolling):

And the same code, but in ItemDecorator getItemOffsets :

source share