get Desired Text Height - Android android.text

Android examples for android.text:TextPaint

Description

get Desired Text Height

Demo Code

import android.graphics.Paint.FontMetrics;
import android.text.TextPaint;

public class Main {

  public static float getDesiredHeight(TextPaint paint) {
    FontMetrics fm = paint.getFontMetrics();
    return (float) Math.ceil(fm.descent - fm.ascent);
  }/*from w ww  .java2  s . co m*/

}

Related Tutorials