在开发中,有时候要获取文字的宽度以更好的布局,偶然的机会看了《professional android app devlopment》发现了这样的写法,实在太酷了。
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应用开发过程中如何利用专业书籍中的技巧,通过实例展示了如何测量文本宽度以实现更精确的布局。通过实例代码演示了测量文本宽度的方法,并解释了其在实际开发中的应用。

被折叠的 条评论
为什么被折叠?



