首页 > 代码库 > android获取文字宽度

android获取文字宽度

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);