4.3.1 类Paint基础
更新于 2026年10月10日
版权声明
4.3.1 类Paint基础
在类Paint中的常用方法如下
(1)void reset():实现重置功能。
(2)void setARGB(int a,int r,int g,int b)或void setColor(int color):均为设置Paint对象颜色的方法。
(3)void setAntiAlias(boolean aa):是否抗锯齿,需要配合void setFlags(Paint.ANTI_ ALIAS_FLAG)方法来帮助消除锯齿使其边缘更平滑。
(4)Shader setShader(Shader shader):设置阴影,Shader类是一个矩阵对象,如果为NULL将清除阴影。(https://www.daowen.com)
(5)void setStyle(Paint.Style style):设置样式,一般为Fill填充,或者STROKE凹陷效果。
(6)void setTextSize(float textSize):设置字体大小。
(7)void setTextAlign(Paint.Align align):文本对齐方式。
(8)Typeface setTypeface(Typeface typeface):用于设置字体,通过Typeface可以加载Android内部的字体,对于中文来说一般为宋体,可以根据需要来自己添加部分字体,例如雅黑等。
(9)void setUnderlineText(boolean underlineText):表示是否设置下划线。