获取文字的宽度(android)
2012-02-27 23:01
246 查看
在开发中,有时候要获取文字的宽度以更好的布局
Java代码
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);
Java代码
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);
相关文章推荐
- android 中 获取 文字宽度
- Android 学习 之 图形绘制篇 获取要绘制的文字的宽度/长度
- android--获取文字的宽度
- Android 获取文字的宽度、高度
- Android 获取控件高度宽度三种方法,防止0的出现,计算空间宽度,文字宽度
- android如何获取屏幕宽度和高度
- Android 获取屏幕高度,宽度,状态栏高度
- 关于在android onCreate()中不能获取控件宽度、大小等的解决办法
- android 获取屏幕高度,宽度,状态栏高度
- Android中获取字符串长度、宽度(所占像素宽度)
- android 获取屏幕高度和宽度 的方法
- Android中获取屏幕高度和宽度
- Android获取View的宽度和高度
- Android:获取屏幕的宽度和高度
- Android drawText获取text宽度的三种方式
- android 获取屏幕高度和宽度的方法
- Android中获取文本宽度和高度
- android之获取屏幕的宽度和高度
- Android手机获取屏幕分辨率(屏幕高度和宽度)
- Android 获取控件高度宽度三种方法