计算textview 文字宽度

来源:互联网 发布:foreach遍历数组 编辑:程序博客网 时间:2024/05/17 06:10
// 计算出该TextView中文字的长度(像素)  
public static float getTextViewLength(TextView textView,String text){  
TextPaint paint = textView.getPaint();  
// 得到使用该paint写上text的时候,像素为多少  
float textLength = paint.measureText(text);  
return textLength;  
}  
1 0
原创粉丝点击