Android examples for Graphics:Canvas
calculate Y When Text Align Center on Canvas
//package com.java2s; import android.graphics.Paint; public class Main { public static float calcYWhenTextAlignCenter(int aCanvasHeight, Paint aPaint) {//w w w. j av a 2 s . c o m if (aPaint == null) { return 0; } final float fontHeight = aPaint.getFontMetrics().bottom - aPaint.getFontMetrics().top; return ((aCanvasHeight - fontHeight) / 2 - aPaint.getFontMetrics().top); } }