1

I want to draw a text in the SurfaceView look like the image given below

enter image description here

How can i do this. Please help me.

4

1 に答える 1

1

replace your onDraw( Canvas canvas ) method with the following code.

@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(); 
}
于 2013-01-11T05:04:33.697 に答える