Java代码
  1. Paint mTextPaint = new Paint(Paint.ANTI_ALIAS_FLAG);   
  2. mTextPaint.setColor(Color.WHITE);   
  3. // Define the string.   
  4. String displayText = “Hello World!”;   
  5. // Measure the width of the text string.   
  6. float textWidth = mTextPaint.measureText(displayText);  

相关文章: