Java tutorial
//package com.java2s; import android.graphics.Paint; import android.graphics.Rect; public class Main { public static Rect getTextRec(String text, Paint paint, float textSize) { Rect rect = new Rect(); if (paint != null && text != null) { if (0 < textSize) { paint.setTextSize(textSize); } paint.getTextBounds(text, 0, text.length(), rect); } return rect; } }