Java tutorial
//package com.java2s; import android.content.Context; import android.content.res.Resources; import android.graphics.Paint.FontMetrics; import android.text.TextPaint; import android.util.TypedValue; public class Main { public static int getFontHeight(Context context, float fontSize) { TextPaint paint = new TextPaint(); setTextSize(context, paint, fontSize); FontMetrics fm = paint.getFontMetrics(); return (int) Math.ceil(fm.descent - fm.ascent); } public static TextPaint setTextSize(Context c, TextPaint paint, float size) { Resources r; if (c == null) { r = Resources.getSystem(); } else { r = c.getResources(); } if (r != null) { paint.setTextSize(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, size, r.getDisplayMetrics())); } return paint; } }