android--获取文字的宽度

来源:互联网 发布:java中常用的算法 编辑:程序博客网 时间:2024/05/18 02:35
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);



取得文字的宽度