我想在SurfaceView中绘制一个文本,如下图所示
我该怎么办?请帮帮我。
答案 0 :(得分:1)
使用以下代码替换onDraw(Canvas canvas)方法。
@Override
protected void onDraw(Canvas canvas)
{
canvas.drawColor( Color.WHITE );
int cx = 240; // screenWidth/2
int cy = 400; // screenHeight/2
Paint paint = new Paint();
paint.setTextSize(30);
paint.setColor( Color.BLACK );
paint.setAntiAlias(true);
canvas.drawText("Name: A", 20, 40, paint);
canvas.save();
canvas.rotate(180, 240, 400);
canvas.drawText("Name: B", 20, 40,paint);
canvas.restore();
}