GcsSloop / AndroidNote

安卓学习笔记
http://www.gcssloop.com/#blog
9.17k stars 2.14k forks source link

drawText的问题 #23

Closed ghost closed 8 years ago

ghost commented 8 years ago
        mPaint = new Paint();
        mPaint.setColor(Color.RED);
        mPaint.setStyle(Paint.Style.FILL);
        mPaint.setStrokeWidth(10f);
        mPaint.setAntiAlias(true);
mCoordinatePaint = new Paint();
mCoordinatePaint.setColor(Color.BLACK);
mCoordinatePaint.setStyle(Paint.Style.FILL);
mCoordinatePaint.setStrokeWidth(10f);
mCoordinatePaint.setAntiAlias(true);

}


@Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
canvas.drawLine(200, 0, 200, 500, mCoordinatePaint);
canvas.drawLine(0, 500, 200, 500, mCoordinatePaint);
mPaint.setTextSize(100);
canvas.drawText("ABCD", 200, 500, mPaint);

}

绘制出来的结果我发现绘制的文字的原点是左下角(也就是文字的左下角才是200,500这个位置)

GcsSloop commented 8 years ago

drawText部分有错误,稍后会补,默认点的基准线的确在文字下方。