1, when we know that the OnDraw () method in Custom view is used for drawing graphics, and the path class is one of the important classes, such as effects:
There's no difficulty in code, just post it.
@Override protected void OnDraw (canvas canvas) { canvas.drawcolor (color.white); Paint paint = new paint (); Paint.setantialias (true); Paint.setcolor (0xffff6600); Paint.settextsize (+); Paint.setstyle (Paint.Style.STROKE); Draw around the circular text path PATH = new Path (); Add clockwise circular path path.addcircle (200,200,100, Path.Direction.CW); Paint.setstyle (Paint.Style.FILL); Canvas.drawtextonpath ("The Moonlight in front of the bed, suspected to be ground frost." Jutou looked at the moon, bowed his head and thought of home. ", path,0,-18,paint); }
Draw the triangle as follows:
The code is as follows:
Canvas.drawcolor (color.white); Paint paint = new paint (); Paint.setantialias (true); Paint.setcolor (0xffff6600); Paint.settextsize (+); Paint.setstyle (Paint.Style.STROKE); Draw the triangle path, path path = new Path (); Set the starting point of the curve Path.moveto (+); Sets the end point of the first edge Path.lineto (+); Set the end point of the second edge Path.lineto (+); Closed path path.close (); Paint.setcolor (color.red); Canvas.drawpath (path, paint);
Draw a polyline
The code is as follows:
Path PATH = new Path (); Path.moveto (a); Path.lineto (250,200); Path.lineto (300,250); Path.lineto (350,400); Path.lineto (400,310); Path.lineto (500,100); Canvas.drawpath (path, paint);
Android--Custom View Mini demo, about the use of the path Class (i)