我创建了一个 Android 应用程序。它使用 aWebView来上传本地 html。但它开始得很慢。它会在大约 10 秒内上传页面。为什么这么慢?有什么方法可以让应用程序启动得更快?
可能重复:
如何在Android上获取字符串宽度?
我使用以下代码来计算字符串的宽度,但宽度的结果与TextView中显示的宽度有很大不同.我怎样才能正确地做到这一点?谢谢你的建议.
Paint paint= new Paint();
paint.setTextSize(size);
int iRet = 0;
if (str != null && str.length() > 0) {
int len = str.length();
float[] widths = new float[len];
paint.getTextWidths(str, widths);
for (int j = 0; j < len; j++) {
iRet += (int) Math.ceil(widths[j]);
}
}
return iRet;
Run Code Online (Sandbox Code Playgroud)