Android怎样获取文字的宽度

  次阅读 作者:智能小宝 来源:互联网 2016-01-14 12:24 我要评论(0)

关键代码

Paint mTextPaint = new Paint(Paint.ANTI_ALIAS_FLAG);

mTextPaint.setColor(Color.WHITE);

// Define the string.

String displayText = "Hello World!";

// Measure the width of the text string.

float textWidth = mTextPaint.measureText(displayText);