Java tutorial
//package com.java2s; import android.graphics.Canvas; import android.graphics.Paint; import android.graphics.Rect; public class Main { public static void drawButtonText(Canvas canvas, Paint paint, Rect btnRect, String text) { int nLen = text.length(); canvas.drawText(text, btnRect.left + btnRect.width() / 2 - 4 * nLen, btnRect.top + btnRect.height() / 2 + nLen, paint); } }