本文整理汇总了Java中android.graphics.Paint.DEV_KERN_TEXT_FLAG属性的典型用法代码示例。如果您正苦于以下问题:Java Paint.DEV_KERN_TEXT_FLAG属性的具体用法?Java Paint.DEV_KERN_TEXT_FLAG怎么用?Java Paint.DEV_KERN_TEXT_FLAG使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类android.graphics.Paint
的用法示例。
在下文中一共展示了Paint.DEV_KERN_TEXT_FLAG属性的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setOverlayText
public void setOverlayText(String suraText, String juzText, String pageText, String rub3Text) {
// Calculate page bounding rect from ayahinfo db
if (pageBounds == null) {
return;
}
overlayParams = new OverlayParams();
overlayParams.suraText = suraText;
overlayParams.juzText = juzText;
overlayParams.pageText = pageText;
overlayParams.rub3Text = rub3Text;
overlayParams.paint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DEV_KERN_TEXT_FLAG);
overlayParams.paint.setTextSize(fontSize);
if (!didDraw) {
invalidate();
}
}
示例2: saveMyBitmap
private boolean saveMyBitmap(Bitmap bitmap,String name ,String... str) {
int destWidth = bitmap.getWidth(); //此处的bitmap已经限定好宽高
int destHeight = bitmap.getHeight();
// Log.v("addWatermarkBitmap","width = " + destWidth+" height = "+destHeight);
Bitmap icon = Bitmap.createBitmap(destWidth, destHeight, Bitmap.Config.ARGB_8888); //定好宽高的全彩bitmap
Canvas canvas = new Canvas(icon);//初始化画布绘制的图像到icon上
Paint photoPaint = new Paint(); //建立画笔
photoPaint.setDither(true); //获取跟清晰的图像采样
photoPaint.setFilterBitmap(true);//过滤一些
Rect src = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight());//创建一个指定的新矩形的坐标
Rect dst = new Rect(0, 0, destWidth, destHeight);//创建一个指定的新矩形的坐标
canvas.drawBitmap(bitmap, src, dst, photoPaint);//将photo 缩放或则扩大到 dst使用的填充区photoPaint
Paint textPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DEV_KERN_TEXT_FLAG);//设置画笔
textPaint.setTextSize(destWidth/30);//字体大小
textPaint.setTextAlign(Paint.Align.CENTER);
textPaint.setTypeface(Typeface.DEFAULT_BOLD);//采用默认的宽度
textPaint.setAntiAlias(true); //抗锯齿
textPaint.setStrokeWidth(1);
textPaint.setAlpha(115);
textPaint.setStyle(Paint.Style.STROKE); //空心
textPaint.setColor(Color.WHITE);//采用的颜色
textPaint.setShadowLayer(1f, 0f, 1f, Color.LTGRAY);
int i = 0;
for (String s : str) {
if(!TextUtils.isEmpty(s)) {
i++;
canvas.drawText(s, destWidth / 2, destHeight - 45 * i, textPaint);//绘制上去字,开始未知x,y采用那只笔绘制
}
}
canvas.save(Canvas.ALL_SAVE_FLAG);
canvas.restore();
bitmap.recycle();
return saveMyBitmap(icon,name); //保存至文件
// return true;
}