get Paint Draw Text Y - Android Graphics

Android examples for Graphics:Paint

Description

get Paint Draw Text Y

Demo Code


//package com.java2s;

import android.graphics.Paint;

public class Main {

    public static int getDrawTextY(int textCenterY, Paint paint) {
        return (int) (textCenterY + 0.3 * getDrawTextHeight(paint));
    }//from   w w w  .java2  s. com

    public static int getDrawTextHeight(Paint paint) {
        Paint.FontMetrics fm = paint.getFontMetrics();
        return (int) Math.ceil(fm.descent - fm.ascent);
    }
}

Related Tutorials