Java tutorial
//package com.java2s; import android.graphics.Canvas; import android.graphics.Paint; import android.graphics.Rect; public class Main { public static void drawText(String text, float x, float y, Canvas canvas, Paint paint) { Rect rect = new Rect(); paint.getTextBounds(text, 0, 1, rect); float halfW = paint.measureText(text) / 2; canvas.drawText(text, x - halfW, y + halfW, paint); } }