我正在使用@ font-face/loadDataWithBaseURL在WebView中使用我自己的字體。它可以工作,但我面臨性能問題。每次我使用「loadDataWithBaseURL」更改WebView的內容時,它會重新加載字體,並且花費幾秒鐘。android:WebView和@ font-face,每次都重新加載字體
禁用@ font-face,表現很完美。
TTF放置在資產中,並且每次都從String中加載CSS/html。
試圖使用緩存,但它似乎使用存儲內存中的文件,所以也許它沒有區別。 或者我可能錯誤地使用了它...
myWebView.getSettings().setDomStorageEnabled(true);
String appCachePath = getApplicationContext().getCacheDir().getAbsolutePath();
myWebView.getSettings().setAppCachePath(appCachePath);
myWebView.getSettings().setAppCacheMaxSize(1024*1024*20);
myWebView.getSettings().setAllowFileAccess(true);
myWebView.getSettings().setAppCacheEnabled(true);
請幫忙。
更多信息:
的應用程序內存使用情況不斷增加,並在每個loaddata增長。
Android版本2.3.5。