Paint属性说明

mPaint =new Paint();

mPaint.setColor(Color.RED);  //设置颜色

mPaint.setARGB(255,255,255,0); //设置透明度颜色

mPaint.setAntiAlias(true);  //这是抗锯齿

mPaint.setStyle(Paint.Style.STROKE);  //描边效果 STROKE FILL FILL_AND_STROKE

mPaint.setStrokeWidth(4);  //设置边框宽度

mPaint.setStrokeCap(Paint.Cap.ROUND);  //圆角效果 默认BUTT  圆角ROUND  方角SQUARE


mPaint.setStrokeJoin(Paint.Join.BEVEL);  //拐角效果  默认 MITER尖角  ROUND圆角  BEVEL缺角


mPaint.setShader(new SweepGradient(200,200,Color.RED,Color.BLUE)); //设置渐变渲染器

mPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.ADD));  //设置图层混合模式

mPaint.setColorFilter(new LightingColorFilter(0x00ffff,0x000000)); //设置颜色过滤器

mPaint.setFilterBitmap(true); //设置双线性过滤 像素间过度效果更加平滑,不会出现马赛克块

//画笔遮罩滤镜,传入度数和样式

mPaint.setMaskFilter(new BlurMaskFilter(10,BlurMaskFilter.Blur.NORMAL));

mPaint.setTextScaleX(2); //设置文本缩放倍数

mPaint.setTextSize(38); //设置字体大小

mPaint.setTextAlign(Paint.Align.LEFT); //设置文本对齐方式

mPaint.setUnderlineText(true);  //设置下划线

String str ="Android高级工程师";

Rect rect =new Rect();

mPaint.getTextBounds(str, 0, str.length(), rect);  //测量文本大小,将文本大小信息存放在rect

float measureSize =mPaint.measureText(str);  //获取文本宽度

Paint.FontMetrics metrics =mPaint.getFontMetrics();  //获取字体度量对象

float ascent = metrics.ascent;  //字符最高点到baseline的推荐距离

float top = metrics.top;        //字符最高点到baseline的最大距离

float descent = metrics.descent; //字符最低点到baseline的推荐距离

float bottom = metrics.bottom;  //字符最低点到baseline的最大距离

float leading = metrics.leading; //行间距,即ascent到descent的距离


你可能感兴趣的:(Paint属性说明)