Public Methods | floatascent()
Return the distance above (negative) the baseline (ascent) based on the current typeface and text size.
1.基准点是baseline
2.ascent:是baseline之上至字符最高处的距离
3.descent:是baseline之下至字符最低处的距离
4.leading:是上一行字符的descent到下一行的ascent之间的距离,也就是相邻行间的空白距离
5.top:是指的是最高字符到baseline的值,即ascent的最大值
6.bottom:是指最低字符到baseline的值,即descent的最大值
intbreakText(CharSequence text, int start, int end, boolean measureForwards, float maxWidth, float[] measuredWidth)Measure the text, stopping early if the measured width exceeds maxWidth.
intbreakText(String text, boolean measureForwards, float maxWidth, float[] measuredWidth)Measure the text, stopping early if the measured width exceeds maxWidth.
intbreakText(char[] text, int index, int count, float maxWidth, float[] measuredWidth)Measure the text, stopping early if the measured width exceeds maxWidth.
voidclearShadowLayer()Clear the shadow layer.
floatdescent()Return the distance below (positive) the baseline (descent) based on the current typeface and text size.
intgetAlpha()Helper to getColor() that just returns the color's alpha value.
intgetColor()Return the paint's color.
ColorFiltergetColorFilter()Get the paint's colorfilter (maybe be null).
booleangetFillPath(Path src, Path dst)Applies any/all effects (patheffect, stroking) to src, returning the result in dst.
intgetFlags()Return the paint's flags.
floatgetFontMetrics(Paint.FontMetrics metrics)Return the font's recommended interline spacing, given the Paint's settings for typeface, textSize, etc.
Paint.FontMetricsgetFontMetrics()Allocates a new FontMetrics object, and then calls getFontMetrics(fm) with it, returning the object.
Paint.FontMetricsIntgetFontMetricsInt()intgetFontMetricsInt(Paint.FontMetricsInt fmi)Return the font's interline spacing, given the Paint's settings for typeface, textSize, etc.
floatgetFontSpacing()Return the recommend line spacing based on the current typeface and text size.
intgetHinting()Return the paint's hinting mode.
MaskFiltergetMaskFilter()Get the paint's maskfilter object.
PathEffectgetPathEffect()Get the paint's patheffect object.
RasterizergetRasterizer()Get the paint's rasterizer (or null).
ShadergetShader()Get the paint's shader object.
Paint.CapgetStrokeCap()Return the paint's Cap, controlling how the start and end of stroked lines and paths are treated.
Paint.JoingetStrokeJoin()Return the paint's stroke join type.
floatgetStrokeMiter()Return the paint's stroke miter value.
floatgetStrokeWidth()Return the width for stroking.
Paint.StylegetStyle()Return the paint's style, used for controlling how primitives' geometries are interpreted (except for drawBitmap, which always assumes
FILL_STYLE).
Paint.AligngetTextAlign()Return the paint's Align value for drawing text.
voidgetTextBounds(char[] text, int index, int count, Rect bounds)Return in bounds (allocated by the caller) the smallest rectangle that encloses all of the characters, with an implied origin at (0,0).
voidgetTextBounds(String text, int start, int end, Rect bounds)Return in bounds (allocated by the caller) the smallest rectangle that encloses all of the characters, with an implied origin at (0,0).
voidgetTextPath(String text, int start, int end, float x, float y, Path path)Return the path (outline) for the specified text.
voidgetTextPath(char[] text, int index, int count, float x, float y, Path path)Return the path (outline) for the specified text.
floatgetTextScaleX()Return the paint's horizontal scale factor for text.
floatgetTextSize()Return the paint's text size.
floatgetTextSkewX()Return the paint's horizontal skew factor for text.
intgetTextWidths(String text, float[] widths)Return the advance widths for the characters in the string.
intgetTextWidths(CharSequence text, int start, int end, float[] widths)Return the advance widths for the characters in the string.
intgetTextWidths(String text, int start, int end, float[] widths)Return the advance widths for the characters in the string.
intgetTextWidths(char[] text, int index, int count, float[] widths)Return the advance widths for the characters in the string.
TypefacegetTypeface()Get the paint's typeface object.
XfermodegetXfermode()Get the paint's xfermode object.
final booleanisAntiAlias()Helper for getFlags(), returning true if ANTI_ALIAS_FLAG bit is set AntiAliasing smooths out the edges of what is being drawn, but is has
no impact on the interior of the shape.
final booleanisDither()Helper for getFlags(), returning true if DITHER_FLAG bit is set Dithering affects how colors that are higher precision than the device are
down-sampled.
final booleanisFakeBoldText()Helper for getFlags(), returning true if FAKE_BOLD_TEXT_FLAG bit is set
final booleanisFilterBitmap()Whether or not the bitmap filter is activated.
final booleanisLinearText()Helper for getFlags(), returning true if LINEAR_TEXT_FLAG bit is set
final booleanisStrikeThruText()Helper for getFlags(), returning true if STRIKE_THRU_TEXT_FLAG bit is set
final booleanisSubpixelText()Helper for getFlags(), returning true if SUBPIXEL_TEXT_FLAG bit is set
final booleanisUnderlineText()Helper for getFlags(), returning true if UNDERLINE_TEXT_FLAG bit is set
floatmeasureText(String text)测量字符串的宽度Return the width of the text.
floatmeasureText(CharSequence text, int start, int end)Return the width of the text.
floatmeasureText(String text, int start, int end)Return the width of the text.
floatmeasureText(char[] text, int index, int count)Return the width of the text.
voidreset()重置画笔,回到画笔默认设置Restores the paint to its default settings.
voidset(Paint src)相当于实例化Paint(Paint paint);时设置画笔Copy the fields from src into this paint.
voidsetARGB(int a, int r, int g, int b)设置绘制的颜色,a代表透明度,r,g,b代表颜色值Helper to setColor(), that takes a,r,g,b and constructs the color int
voidsetAlpha(int a)设置透明度值 Helper to setColor(), that only assigns the color's alpha value, leaving its r,g,b values unchanged.
voidsetAntiAlias(boolean aa)设置是否使用抗锯齿功能,会消耗较大资源,绘制图形速度会变慢。,true为无锯齿Helper for setFlags(), setting or clearing the ANTI_ALIAS_FLAG bit AntiAliasing smooths out the edges of what is being drawn,
but is has no impact on the interior of the shape.
voidsetColor(int color)设置绘制的颜色,使用颜色值来表示,该颜色值包括透明度和RGB颜色Set the paint's color.
ColorFiltersetColorFilter(ColorFilter filter)设置颜色过滤器,可以在绘制颜色时实现不用颜色的变换效果Set or clear the paint's colorfilter, returning the parameter.
voidsetDither(boolean dither)设定是否使用图像抖动处理,会使绘制出来的图片颜色更加平滑和饱满,图像更加清晰Helper for setFlags(), setting or clearing the DITHER_FLAG bit Dithering affects how colors that are higher precision than the
device are down-sampled.
voidsetFakeBoldText(boolean fakeBoldText)模拟实现粗体文字,设置在小字体上效果会非常差 Helper for setFlags(), setting or clearing the FAKE_BOLD_TEXT_FLAG bit
voidsetFilterBitmap(boolean filter)
Helper for setFlags(), setting or clearing the FILTER_BITMAP_FLAG bit.
voidsetFlags(int flags)相当于Paint(int flags);时的设置Set the paint's flags.
voidsetHinting(int mode)Set the paint's hinting mode.
voidsetLinearText(boolean linearText)Helper for setFlags(), setting or clearing the LINEAR_TEXT_FLAG bit
MaskFiltersetMaskFilter(MaskFilter maskfilter)设置MaskFilter,可以用不同的MaskFilter实现滤镜的效果,如滤化,立体等Set or clear the maskfilter object.
PathEffectsetPathEffect(PathEffect effect)设置绘制路径的效果,如点画线等Set or clear the patheffect object.
RasterizersetRasterizer(Rasterizer rasterizer)Set or clear the rasterizer object.
ShadersetShader(Shader shader)设置图像效果,使用Shader可以绘制出各种渐变效果Set or clear the shader object.
voidsetShadowLayer(float radius, float dx, float dy, int color)在图形下面设置阴影层,产生阴影效果,radius为阴影的角度,
dx和dy为阴影在x轴和y轴上的距离,color为阴影的颜色This draws a shadow layer below the main layer, with the specified offset and color, and blur radius.
voidsetStrikeThruText(boolean strikeThruText) Helper for setFlags(), setting or clearing the STRIKE_THRU_TEXT_FLAG bit
voidsetStrokeCap(Paint.Cap cap)Cap.ROUND,或方形样式Cap.SQUARE Set the paint's Cap.
voidsetStrokeJoin(Paint.Join join) Set the paint's Join.
voidsetStrokeMiter(float miter)Set the paint's stroke miter value.
voidsetStrokeWidth(float width)当画笔样式为STROKE或FILL_OR_STROKE时,设置笔刷的粗细度Set the width for stroking.
voidsetStyle(Paint.Style style)设置画笔的样式,为FILL,FILL_OR_STROKE,或STROKE 空心或者实心Set the paint's style, used for controlling how primitives' geometries are interpreted
(except for drawBitmap, which always assumes Fill).
voidsetSubpixelText(boolean subpixelText) Helper for setFlags(), setting or clearing the SUBPIXEL_TEXT_FLAG bit
voidsetTextAlign(Paint.Align align)设置绘制文字的对齐方向 Set the paint's text alignment.
voidsetTextScaleX(float scaleX) 设置绘制文字x轴的缩放比例,可以实现文字的拉伸的效果Set the paint's horizontal scale factor for text.
voidsetTextSize(float textSize)设置绘制文字的字号大小Set the paint's text size.
voidsetTextSkewX(float skewX)设置斜体文字,skewX为倾斜弧度 Set the paint's horizontal skew factor for text.
TypefacesetTypeface(Typeface typeface)设置Typeface对象,即字体风格,包括粗体,斜体以及衬线体,非衬线体等Set or clear the typeface object.
voidsetUnderlineText(boolean underlineText) 设置带有下划线的文字效果Helper for setFlags(), setting or clearing the UNDERLINE_TEXT_FLAG bit
XfermodesetXfermode(Xfermode xfermode) Set or clear the xfermode object.