I'm currently working with a RecyclerView
which has an horizontal LinearLayout
. The RecyclerView
occupies all the screen:
and I'm finding the way to make a fix transformation of the RecyclerView
like this:
note that the transformation is like a "sinking" or "downfall" to make a "deep" effect. Since the items' size can change, I need a permanent transformation, that's why I'm thinking to make it in the RecyclerView
Is there anyway to do it? maybe a way to do it on onDraw
??
Thank you very much in advance.
Regards.
Rafael.
ADD:
I'd like to notice that PageTransformer
does something similar. In fact, the thing that I want is very similar of what Samsung Galaxy S3 makes when you scroll with one of their Launchers (which uses ViewPager
), but I'd like to make that transformation fixed:
WHAT AM I TRYING?
I'm trying to scroll a large horizontal adapter of RecyclerView
, but I'd like to "fold" a little bit the view to make a little impression of "cylinder".
make a class that extends RecyclerView
and override its dispatchDraw
(or draw
) method, use Matrix#setPolyToPoly
to make perspective transformation, the below code makes something like "Star Wars" effect, you would need to call setPolyToPoly
twice and apply the Matrix
on both halves of your custom view:
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
final float DELTAX = w * 0.15f;
float[] src = {
0, 0, w, 0, w, h, 0, h
};
float[] dst = {
0, 0, w, 0, w - DELTAX, h, DELTAX, h
};
matrix.setPolyToPoly(src, 0, dst, 0, 4);
}
@Override
protected void dispatchDraw(Canvas canvas) {
canvas.save();
canvas.concat(matrix);
super.dispatchDraw(canvas);
canvas.restore();
}