画板:绘制画面
绘制点_矩形_线
原创
©著作权归作者所有:来自51CTO博客作者Ljj_Tiny的原创作品,如需转载,请与作者联系,否则将追究法律责任
创建一个类,这个类继承View类
在onDraw()方法中绘制
public class MyGridView extends
View{
public MyGridView(Context
context){
super(context);
// TODO Auto-generated
constructor stub
}
@Override
protected void onDraw
(Canvas canvas){
// TODO Auto-generated
method stub
super.onDraw(canvas);
Paint shapePaint = new
Paint();
//设置宽度
shapePaint.setStrokeWidth(2);
canvas.drawPoint
(20,20,shapePaint);
canvas.drawLine
(20,30,20,70,shapePaint);
canvas.drawRect
(20,80,140,shapePaint);
//画空心矩形
shapePaint.setStyle
(Paint.Style.STROKE);
canvas.drawRect
(20,150,80,200,shapePaint);
Rect path = new Path
();
shapePaint.setColor
(Color.GREEN);
path.addCircle
(150,200,50,Direction.CW);
canvas.drawPath
(path,shapePaint);
shapePaint.setTextSize(18);
shapePaint.setFakeBoldText(true);
canvas.drawTextOnPath
("Welcome to my home!",path, 0,
10,shapePaint);
}
}
上一篇:添加背景音乐
下一篇:在画板上画矩形,在矩形中画字
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
ArcEngine绘制点、线、多边形、矩形、圆形、椭圆的代码
熟悉ArcGIS的同志应该知道在ArcMap中编辑shp文件时,我们可以绘制点、线、多边形、矩形、圆形、椭圆等几何em.R...
arcengine 绘制 几何图形 System ide -
Android 画圆角线 android canvas绘制圆角矩形
在做组态的时候,需要支持矩形圆角格式,但是因为canvas本身不带有圆角矩形,需要自行算出坐标进行绘制方案一、统一圆角
Android 画圆角线 Math 圆角矩形 字符串