package com.mz.canvas; import android.content.Context; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; import android.graphics.Path; import android.graphics.Paint.Style; import android.graphics.Path.Direction; import android.view.View; { private Paint paint; private Paint paint1; public MyPathView(Context context) { super(context); paint=new Paint(); paint.setColor(Color.RED);//画笔颜色 paint.setStrokeWidth(2);//画笔宽度 paint.setAntiAlias(true);//抗锯齿 paint.setStyle(Style.STROKE);//样式不填充 paint.setTextSize(20);//字体大小为20 paint1=new Paint(paint);//继承paint paint1.setColor(Color.BLUE); // TODO Auto-generated constructor stub } (Canvas canvas) { // TODO Auto-generated method stub super.onDraw(canvas); canvas.drawColor(Color.WHITE); Path path=new Path();//实例化path path.addCircle(path.addCircle(250, 250, 50, Direction.CW); canvas.drawPath(path, paint); String str="XX大学计算机学院"; canvas.drawTextOnPath(str, path, Path path1=new Path(); path1.moveTo(200, 220); path1.lineTo(70, 300); path1.lineTo(280, 300); path1.close();//自动连线 canvas.drawPath(path1, paint); } }