本文整理匯總了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;
}