canvas教程

android学习 4-25使用Path 绘制几何图形

字号+ 作者:H5之家 来源:H5之家 2018-04-21 13:01 我要评论( )

packagecom.mz.canvas;importandroid.content.Context;importandroid.graphics.Canvas;importandroid.graphics.Color;importandroid.graphics.Paint;importandro

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); } }

 

1.本站遵循行业规范,任何转载的稿件都会明确标注作者和来源;2.本站的原创文章,请转载时务必注明文章作者和来源,不尊重原创的行为我们将追究责任;3.作者投稿可能会经我们编辑修改或补充。

相关文章
  • android canvas.drawBitmap的了解

    android canvas.drawBitmap的了解

    2018-03-30 13:02

  • Android 学习 之 Canvas (1)

    Android 学习 之 Canvas (1)

    2018-03-30 10:02

  • Android canvas用法介绍之save()和restore()

    Android canvas用法介绍之save()和restore()

    2018-03-29 14:05

  • android canvas画图 切割画布(clipRect)

    android canvas画图 切割画布(clipRect)

    2018-03-10 18:05

网友点评