指定path上绘制文字
1 package cn.itcast.welcome; 2 3 import android.content.Context; 4 import android.graphics.Canvas; 5 import android.graphics.Color; 6 import android.graphics.Paint; 7 import android.graphics.Path; 8 import android.graphics.Typeface; 9 import android.view.View; 10 11 public class MyView extends View { 12 13 public MyView(Context context) { 14 super(context); 15 // TODO Auto-generated constructor stub 16 } 17 18 @Override 19 protected void onDraw(Canvas canvas) { 20 21 Paint paint = new Paint(); 22 paint.setColor(Color.GREEN); 23 paint.setTextSize(20); 24 paint.setTypeface(Typeface.DEFAULT); 25 Path p = new Path(); 26 p.moveTo(20, 20); 27 p.lineTo(100, 150); 28 p.lineTo(200, 220); 29 canvas.drawTextOnPath("Hello this is text on a path", p, 0, 0, paint); 30 31 32 33 super.onDraw(canvas); 34 } 35 }