Java tutorial
//package com.java2s; import android.graphics.Paint; public class Main { /** * * @param paint * @param cellHeight * @return */ public static float getTextFitY(Paint paint, float cellHeight) { Paint.FontMetrics fm = paint.getFontMetrics(); float textHeight = (float) (Math.ceil(fm.descent - fm.ascent) + 2f); return (cellHeight + textHeight) / 2 - fm.bottom; } }