Java tutorial
//package com.java2s; import android.graphics.Paint; public class Main { public static float calcYWhenTextAlignCenter(int aCanvasHeight, Paint aPaint) { if (aPaint == null) { return 0; } final float fontHeight = aPaint.getFontMetrics().bottom - aPaint.getFontMetrics().top; return ((aCanvasHeight - fontHeight) / 2 - aPaint.getFontMetrics().top); } }