Get Text Width : Text « 2D Graphics « Android






Get Text Width

   
import android.graphics.Paint;

class Main {
  public static float GetTextWidth(String Sentence, float Size) {
    Paint FontPaint = new Paint();
    FontPaint.setTextSize(Size);
    return FontPaint.measureText(Sentence.trim()) + (int) (Size * 0.1); // ???????
  }
}

   
    
    
  








Related examples in the same category

1.Set Paint Text size
2.Draw text
3.Text on a Path
4.Text Align
5.Measure Text
6.Using Spannable text and set style
7.Rotate and transformation