Android examples for Graphics:Bitmap Paint
draw Text At Bitmap
//package com.java2s; import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.Paint; import android.graphics.PorterDuffXfermode; public class Main { public static void drawTextAtBitmap(Bitmap bitmap, String s) { if (bitmap == null) { return; } else {//from w w w .j av a 2 s . c o m Paint paint = new Paint(); paint.setTextSize(20F); paint.setColor(0xff0000ff); paint.setAntiAlias(true); paint.setXfermode(new PorterDuffXfermode( android.graphics.PorterDuff.Mode.SRC)); paint.setTextAlign(android.graphics.Paint.Align.CENTER); paint.setShadowLayer(1.0F, 0.0F, 0.0F, -1); Canvas canvas = new Canvas(bitmap); android.graphics.Paint.FontMetrics fontmetrics = paint .getFontMetrics(); canvas.drawText( s, (1 + bitmap.getWidth()) / 2, ((float) bitmap.getHeight() - (fontmetrics.descent + fontmetrics.ascent)) / 2.0F, paint); return; } } }