Android examples for android.graphics:Paint
get string Pixel Width
import android.graphics.Paint; import android.graphics.Rect; public class Main { public static int getPixWidth(String str, Paint paint) { Rect rect = new Rect(); paint.getTextBounds(str, 0, str.length(), rect); return rect.width(); }//ww w. j a va 2 s .co m }