小编Li *_*Che的帖子

Android webview 应用启动太慢。

我创建了一个 Android 应用程序。它使用 aWebView来上传本地 html。但它开始得很慢。它会在大约 10 秒内上传页面。为什么这么慢?有什么方法可以让应用程序启动得更快?

android webview android-webview

5
推荐指数
1
解决办法
6994
查看次数

如何计算字符串的宽度

可能重复:
如何在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)

android

2
推荐指数
1
解决办法
362
查看次数

标签 统计

android ×2

android-webview ×1

webview ×1