get Paint Font Height - Android Graphics

Android examples for Graphics:Paint

Description

get Paint Font Height

Demo Code


//package com.java2s;

import android.graphics.Paint;
import android.graphics.Paint.FontMetrics;

public class Main {

    public static int getFontHeight(float textSize) {
        Paint paint = new Paint();
        paint.setTextSize(textSize);/*from www. j  av  a 2s .  c o  m*/
        FontMetrics fm = paint.getFontMetrics();

        return (int) Math.ceil(fm.descent - fm.top) + 2;
    }
}

Related Tutorials