Here you can find the source of getStringsWidth(TextPaint paint, String text)
Parameter | Description |
---|---|
paint | a parameter |
text | a parameter |
public static int getStringsWidth(TextPaint paint, String text)
//package com.java2s; import android.graphics.Rect; import android.text.TextPaint; public class Main { /**//from w w w. jav a 2 s. c o m * get the width for a string with specified paint. * @Title: getStringsWidth * @Description: TODO * @param paint * @param text * @return string width * @return: int */ public static int getStringsWidth(TextPaint paint, String text) { Rect rect = new Rect(); paint.getTextBounds(text, 0, text.length(), rect); return rect.width(); } }