前言:
上一篇文章讲述了通过Camera, Matrix 3d旋转+RecyclerView实现和(IOS时间地址选择3D)滚轮控件一样效果的WheelView,但是只限于画不同颜色的文本,如果要实现适配器中任意布局,就需要另一种实现方式
更多文章请关注:http://www.jianshu.com/u/b1cff340957c
效果图
由于原理与上篇文章讲述差不多,就不再详细介绍,旋转的逻辑放到RecyclerView的drawChild中实现
@Override
public boolean drawChild(Canvas canvas, View child, long drawingTime) {
canvas.save();
if (orientation == LinearLayoutManager.VERTICAL) {
//垂直方向旋转画笔,再画child
verticalCanvasForDrawChild(canvas, child, translateX(centerX));
} else {
//水平方向旋转画笔,再画child
horizontalCanvasForDrawChild(canvas, child);
}
boolean drawChild = super.drawChild(canvas, child, drawingTime);
canvas.restore();
return drawChild;
}