canvas.drawpath不适合我

时间:2015-06-09 03:35:23

标签: android canvas

    int size = 500;
    int xInterval = 30;

    for (int i = 0; i < size; i++) {
        float x = xInterval * i;
        float y = (float) (Math.random() * 300);

        if (i == 0) {
            mLinePath.moveTo(x, y);
        } else {
            mLinePath.lineTo(x, y);
        }

        canvas.drawText(i + "", x, y, mTextPaint);
    }

    canvas.drawPath(mLinePath, mLinePaint);

我把上面的代码放在onDraw方法中,但路径没有显示,文字显示,我怀疑点大小是否过大?我怎么解决这个问题? 并初始化了涂料的代码:

    mLinePaint = new Paint();
    mLinePaint.setAntiAlias(true);
    mLinePaint.setDither(true);
    mLinePaint.setStyle(Paint.Style.STROKE);
    mLinePaint.setColor(Color.WHITE);

    mTextPaint = new Paint();
    mTextPaint.setAntiAlias(true);
    mTextPaint.setDither(true);
    mTextPaint.setStyle(Paint.Style.FILL);
    mTextPaint.setColor(Color.WHITE);

0 个答案:

没有答案