public class

Paint

extends Object
java.lang.Object
android.graphics.Paint
Known Direct Subclasses TextPaint

Class Overview

The Paint class holds the style and color information about how to draw geometries, text and bitmaps.

enum Paint.Align Align specifies how drawText aligns its text relative to the [x,y] coordinates.
enum Paint.CapThe Cap specifies the treatment for the beginning and ending of stroked lines and paths.
class Paint.FontMetrics Class that describes the various metrics for a font at a given text size.
class Paint.FontMetrics IntConvenience method for callers that want to have FontMetrics values as integers.
enum Paint.Join The Join specifies the treatment where lines and curve segments join on a stroked path.
enum Paint.Style The Style specifies if the primitive being drawn is filled, stroked, or both (in the same color).

Summary

Public Constructors
Paint() 创建默认设置的画笔 Create a new paint with default settings.
Paint(int flags) 创建指定标记的画笔,类似于给画笔取了个名字 Create a new paint with the specified flags.
Paint( Paintpaint) 创建和现有画笔属性相同的画笔 Create a new paint, initialized with the attributes in the specified paint parameter.
Public Methods
float ascent()
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的最大值

int breakText( CharSequencetext, int start, int end, boolean measureForwards, float maxWidth, float[] measuredWidth) Measure the text, stopping early if the measured width exceeds maxWidth.
int breakText( Stringtext, boolean measureForwards, float maxWidth, float[] measuredWidth) Measure the text, stopping early if the measured width exceeds maxWidth.
int breakText(char[] text, int index, int count, float maxWidth, float[] measuredWidth) Measure the text, stopping early if the measured width exceeds maxWidth.
void clearShadowLayer() Clear the shadow layer.
float descent() Return the distance below (positive) the baseline (descent) based on the current typeface and text size.
int getAlpha() Helper to getColor() that just returns the color's alpha value.
int getColor() Return the paint's color.
ColorFilter getColorFilter() Get the paint's colorfilter (maybe be null).
boolean getFillPath( Pathsrc, Pathdst) Applies any/all effects (patheffect, stroking) to src, returning the result in dst.
int getFlags() Return the paint's flags.
float getFontMetrics( Paint.FontMetricsmetrics) Return the font's recommended interline spacing, given the Paint's settings for typeface, textSize, etc.
Paint.FontMetrics getFontMetrics() Allocates a new FontMetrics object, and then calls getFontMetrics(fm) with it, returning the object.
Paint.FontMetricsInt getFontMetricsInt()
int getFontMetricsInt( Paint.FontMetricsIntfmi) Return the font's interline spacing, given the Paint's settings for typeface, textSize, etc.
float getFontSpacing() Return the recommend line spacing based on the current typeface and text size.
int getHinting() Return the paint's hinting mode.
MaskFilter getMaskFilter() Get the paint's maskfilter object.
PathEffect getPathEffect() Get the paint's patheffect object.
Rasterizer getRasterizer() Get the paint's rasterizer (or null).
Shader getShader() Get the paint's shader object.
Paint.Cap getStrokeCap() Return the paint's Cap, controlling how the start and end of stroked lines and paths are treated.
Paint.Join getStrokeJoin() Return the paint's stroke join type.
float getStrokeMiter() Return the paint's stroke miter value.
float getStrokeWidth() Return the width for stroking.
Paint.Style getStyle() Return the paint's style, used for controlling how primitives' geometries are interpreted (except for drawBitmap, which always assumes FILL_STYLE).
Paint.Align getTextAlign() Return the paint's Align value for drawing text.
void getTextBounds(char[] text, int index, int count, Rectbounds) Return in bounds (allocated by the caller) the smallest rectangle that encloses all of the characters, with an implied origin at (0,0).
void getTextBounds( Stringtext, int start, int end, Rectbounds) Return in bounds (allocated by the caller) the smallest rectangle that encloses all of the characters, with an implied origin at (0,0).
void getTextPath( Stringtext, int start, int end, float x, float y, Pathpath) Return the path (outline) for the specified text.
void getTextPath(char[] text, int index, int count, float x, float y, Pathpath) Return the path (outline) for the specified text.
float getTextScaleX() Return the paint's horizontal scale factor for text.
float getTextSize() Return the paint's text size.
float getTextSkewX() Return the paint's horizontal skew factor for text.
int getTextWidths( Stringtext, float[] widths) Return the advance widths for the characters in the string.
int getTextWidths( CharSequencetext, int start, int end, float[] widths) Return the advance widths for the characters in the string.
int getTextWidths( Stringtext, int start, int end, float[] widths) Return the advance widths for the characters in the string.
int getTextWidths(char[] text, int index, int count, float[] widths) Return the advance widths for the characters in the string.
Typeface getTypeface() Get the paint's typeface object.
Xfermode getXfermode() Get the paint's xfermode object.
final boolean isAntiAlias() 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 boolean isDither() 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 boolean isFakeBoldText() Helper for getFlags(), returning true if FAKE_BOLD_TEXT_FLAG bit is set
final boolean isFilterBitmap() Whether or not the bitmap filter is activated.
final boolean isLinearText() Helper for getFlags(), returning true if LINEAR_TEXT_FLAG bit is set
final boolean isStrikeThruText() Helper for getFlags(), returning true if STRIKE_THRU_TEXT_FLAG bit is set
final boolean isSubpixelText() Helper for getFlags(), returning true if SUBPIXEL_TEXT_FLAG bit is set
final boolean isUnderlineText() Helper for getFlags(), returning true if UNDERLINE_TEXT_FLAG bit is set
float measureText( Stringtext) 测量字符串的宽度 Return the width of the text.
float measureText( CharSequencetext, int start, int end) Return the width of the text.
float measureText( Stringtext, int start, int end) Return the width of the text.
float measureText(char[] text, int index, int count) Return the width of the text.
void reset() 重置画笔,回到画笔默认设置 Restores the paint to its default settings.
void set( Paintsrc) 相当于实例化Paint(Paintpaint);时设置画笔 Copy the fields from src into this paint.
void setARGB(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
void setAlpha(int a) 设置透明度 Helper to setColor(), that only assigns the color's alpha value, leaving its r,g,b values unchanged.
void setAntiAlias(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.
void setColor(int color) 设置绘制的颜色,使用颜色值来表示,该颜色值包括透明度和RGB颜色 Set the paint's color.
ColorFilter setColorFilter( ColorFilterfilter) 设置颜色过滤器,可以在绘制颜色时实现不用颜色的变换效果 Set or clear the paint's colorfilter, returning the parameter.
void setDither(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.
void setFakeBoldText(boolean fakeBoldText) 模拟实现粗体文字,设置在小字体上效果会非常差 Helper for setFlags(), setting or clearing the FAKE_BOLD_TEXT_FLAG bit
void setFilterBitmap(boolean filter) 如果该项设置为true,则图像在动画进行中会滤掉对Bitmap图像的优化操作,加快显示
速度,本设置项依赖于dither和xfermode的设置 Helper for setFlags(), setting or clearing the FILTER_BITMAP_FLAG bit.
void setFlags(int flags) 相当于Paint(int flags);时的设置 Set the paint's flags.
void setHinting(int mode) Set the paint's hinting mode.
void setLinearText(boolean linearText) Helper for setFlags(), setting or clearing the LINEAR_TEXT_FLAG bit
MaskFilter setMaskFilter( MaskFiltermaskfilter) 设置MaskFilter,可以用不同的MaskFilter实现滤镜的效果,如滤化,立体等 Set or clear the maskfilter object.
PathEffect setPathEffect( PathEffecteffect) 设置绘制路径的效果,如点画线等 Set or clear the patheffect object.
Rasterizer setRasterizer( Rasterizerrasterizer) Set or clear the rasterizer object.
Shader setShader( Shadershader) 设置图像效果,使用Shader可以绘制出各种渐变效果 Set or clear the shader object.
void setShadowLayer(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.
void setStrikeThruText(boolean strikeThruText) 设置带有删除线的效果 Helper for setFlags(), setting or clearing the STRIKE_THRU_TEXT_FLAG bit
void setStrokeCap( Paint.Capcap) 当画笔样式为STROKE或FILL_OR_STROKE时,设置笔刷的图形样式,如圆形样式
Cap.ROUND,或方形样式Cap.SQUARE Set the paint's Cap.
void setStrokeJoin( Paint.Joinjoin) 设置绘制时各图形的结合方式,如平滑效果等 Set the paint's Join.
void setStrokeMiter(float miter) Set the paint's stroke miter value.
void setStrokeWidth(float width) 当画笔样式为STROKE或FILL_OR_STROKE时,设置笔刷的粗细度 Set the width for stroking.
void setStyle( Paint.Stylestyle) 设置画笔的样式,为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).
void setSubpixelText(boolean subpixelText) 设置该项为true,将有助于文本在LCD屏幕上的显示效果 Helper for setFlags(), setting or clearing the SUBPIXEL_TEXT_FLAG bit
void setTextAlign( Paint.Alignalign) 设置绘制文字的对齐方向 Set the paint's text alignment.
void setTextScaleX(float scaleX) 设置绘制文字x轴的缩放比例,可以实现文字的拉伸的效果 Set the paint's horizontal scale factor for text.
void setTextSize(float textSize) 设置绘制文字的字号大小 Set the paint's text size.
void setTextSkewX(float skewX) 设置斜体文字,skewX为倾斜弧度 Set the paint's horizontal skew factor for text.
Typeface setTypeface( Typefacetypeface) 设置Typeface对象,即字体风格,包括粗体,斜体以及衬线体,非衬线体等 Set or clear the typeface object.
void setUnderlineText(boolean underlineText) 设置带有下划线的文字效果 Helper for setFlags(), setting or clearing the UNDERLINE_TEXT_FLAG bit
Xfermode setXfermode( Xfermodexfermode) 设置图形重叠时的处理方式,如合并,取交集或并集,经常用来制作橡皮的擦除效果 Set or clear the xfermode object.
Protected Methods
void finalize() Invoked when the garbage collector has detected that this instance is no longer reachable.








更多相关文章

  1. Android布局颜色对应值
  2. Android(安卓)ProgressBar的动画效果
  3. Android几种强大的下拉刷新库
  4. xml中自定义图形
  5. android圆盘菜单效果
  6. Android(安卓)8.0 通知栏的适配
  7. Android之自定义最简单的竖向引导页
  8. 自定义React Native Modal,支持全屏弹框
  9. uniapp自定义弹窗组件|Modal模态框|Loading加载框

随机推荐

  1. Linux或Linux虚拟机桥接模式使用Python2
  2. [LeetCode][Python][C#]刷题记录 1. 两数
  3. Python3基础教程-廖雪峰[带标签完整版]
  4. wxPython 显示一张图片
  5. eclipse调用python模块是出错及解决
  6. py2exe使用相对路径的当前目录问题
  7. Python里如何取得第一个光驱的盘符???
  8. Python进阶----类的结构(公有成员 , 私有
  9. Python中的装饰器——11
  10. 学习笔记(11月02日)--高阶函数