2012-06-28 11 views
7

下の図のようにキャンバスにテキストを描画するには、Green rectangleでハイライトします。角度でキャンバスにテキストを描く

enter image description here

私は、次のコードを行っている....しかし、このコードから私はstraightでテキストを書くことができます。 angleにテキストを書き込めません。

Bitmap bmpLayered = Bitmap.createBitmap(bmpMain.getWidth(), bmpMain 
       .getHeight(), Bitmap.Config.ARGB_8888); 
     Canvas cv = new Canvas(bmpLayered); 

Paint charPaint = new Paint(); 
     charPaint.setAntiAlias(true); 
     charPaint.setStyle(Paint.Style.FILL); 
     charPaint.setTextSize(24); 
     charPaint.setColor(Color.BLACK); 
     charPaint.setStrokeWidth(3); 

cv.drawText("None", 570, 222, charPaint); 

これを解決するのを手伝ってください。

ありがとうございました。

CVがあなたのキャンバスを参照すること

答えて

23
cv.save(); 
cv.rotate(-45, x, y); 
cv.drawText("your text here", x, y, paint); 
cv.restore(); 

は、あなたが描きたい& yのポイントをxは。

+0

おかげで... – Nikhil

1

テキストをキャンバスに描画したら、キャンバスを回転させることができます。それが働いている

cv.drawText("None", 570, 222, charPaint); 
//rotate the canvas 
cv.rotate(45f); 
// or around a pivot point 
cv.rotate(45f, 100, 100); 

Android Developer: Graphics-Canvas Rotate

+0

それは..dear作業ではありません – Nikhil

関連する問題