youxiaochen/WheelView-3d

请教下 如果定位在第一条数据怎么搞啊

Opened this issue · 0 comments

void verticalCanvasForDrawChild(Canvas c, View child, float translateX) {

    float itemCenterY = (child.getTop() + child.getBottom()) * 0.5f;

// float itemCenterY = (child.getTop() + child.getBottom());

    float scrollOffY = itemCenterY - centerY;
    Log.i("kaka","===child.getTop()="+child.getTop());
    Log.i("kaka","===child.getBottom()="+child.getBottom());
    Log.i("kaka","===itemCenterY="+itemCenterY);
    Log.i("kaka","===scrollOffY="+scrollOffY);

    float rotateDegreeX = rotateLimitRightAngle(scrollOffY * itemDegree / itemSize);//垂直布局时要以X轴为中心旋转
    float rotateSinX = (float) Math.sin(Math.toRadians(rotateDegreeX));
    float rotateOffY = scrollOffY - wheelRadio * rotateSinX;//因旋转导致界面视角的偏移
    //Log.i("you", "drawVerticalItem degree " + rotateDegreeX);

    c.translate(0.0f, -rotateOffY);//因旋转导致界面视角的偏移
    camera.save();

    //旋转时离视角的z轴方向也会变化,先移动Z轴再旋转
    float z = (float) (wheelRadio * (1 - Math.abs(Math.cos(Math.toRadians(rotateDegreeX)))));
    camera.translate(0, 0, z);


    camera.rotateX(-rotateDegreeX);
    camera.getMatrix(matrix);
    camera.restore();
    matrix.preTranslate(-translateX, -itemCenterY);
    matrix.postTranslate(translateX, itemCenterY);
    c.concat(matrix);
}

我想主要代码应该是改这块