@Overrideprotected void onDraw(Canvas canvas) { super.onDraw(canvas); Path path = new Path(); path.reset(); path.moveTo(500,500); path.lineTo(1000,1000); Paint mPaint = new Paint(); //参考下面6行 mPaint.setStrokeWidth(5f); mPaint.setColor(Color.RED); mPaint.setDither(true); mPaint.setStyle(Paint.Style.STROKE); mPaint.setStrokeJoin(Paint.Join.ROUND); mPaint.setStrokeCap(Paint.Cap.ROUND); canvas.drawPath(path,mPaint);}