What are the common methods of Android drawing, the following one by one for you to enumerate:
1, about the brush (Paint) method
Paint mpaint= new Paint ();
Mpaint.setantialias (TRUE); Anti-aliasing
mpaint.setstrokewidth (mcirclewidth);//Set the width of the ring
Mpaint.setstrokecap (Paint.Cap.ROUND); Defines a segment breakpoint shape as rounded head
Mpaint.setantialias (TRUE);//Anti-aliasing
Mpaint.setstyle (Paint.Style.STROKE);//Set Hollow
Mpaint.descent ()//is the distance below baseline to the lowest point of the character
mpaint.ascent ()/is the distance above baseline to the top of the character
2, about the canvas (Canvas) method
How to create a new canvas
Create a canvas directly
Canvas Canvas = new Canvas ();
Create a canvas with the specified Bitmap background
Bitmap Bitmap = Bitmapfactory.decoderesource (Getresources (), r.drawable.ic_launcher);
Canvas canvas2 = new Canvas (bitmap);
A summary of some common methods of drawing canvas
Used to save the state of canvas. Save, you can call the canvas translation, scaling, rotation, error-cut, cropping and other operations.
Canvas.save ();
The state to save before the canvas is restored. The actions performed against canvas after save have an effect on subsequent rendering.
//save and restore are paired with (restore can be less than save, but not many), and error is raised if the restore call is more than save.
Canvas.restore ();
Move the coordinate origin to the specified position
ccanvas.translate (x,y);
Summary of common drawing methods
/** Draw arc, fan/
Canvas.drawarc (oval,//arc
is the rectangle startangle,//the starting angle
sweepangle,//rotation angle usecenter
,/ True to draw the pie, false is curved
paint);//Brush
/** Draw Text
/canvas.drawtext (text,//text content
x, y,///Draw text start coordinates (upper left)
paint);//Draw The brush of the text
/** draw Line/
Canvas.drawline (startx, starty,//start xy coordinate
stopx, stopy,//end XY coordinates
paint)//Draw a line with the brush
canvas.drawlines (pts,////the set of end points that draw the line, each line occupies 4 data.
paint)//The drawing uses the brush
canvas.drawlines (pts,//the set of end points that draw the line, each line occupies 4 data.) The
number of offset,//skipped data that will not participate in the drawing process.
count,//The number of data actually involved in drawing.
paint)//drawing
/** Drawing Rectangle/
canvas.drawrect (float x1,float y1,//Draw Rectangle Upper-left corner vertex coordinates
float x2,float y2,/ /Draw Rectangle Right corner vertex coordinate
Paint Paint);//Drawing brush
The above is the common method of the Android drawing, hope to be helpful to everybody's study.