最佳的WebView设置HTML5的支持?WebView

2023-09-06 13:36:30 作者:願人生無可辜負

我感兴趣的是确定最佳的设置是干什么用一个web视图,旨在展示HTML5的内容。

I'm interested in determining what the optimal settings are for a WebView that is intended to show HTML5 content.

目前我使用的:

mWebView.setFocusable(true);
mWebView.setFocusableInTouchMode(true);
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.getSettings().setPluginsEnabled(true);
mWebView.getSettings().setRenderPriority(RenderPriority.HIGH);
mWebView.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
mWebView.getSettings().setDomStorageEnabled(true);
mWebView.getSettings().setDatabaseEnabled(true);
mWebView.getSettings().setAppCacheEnabled(true);
mWebView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);

使用这些设置,web视图得分189(W / 1奖金)在 html5test.com 。我想知道,如果有,我应该/可以改变,以获得与HTML5的兼容性的任何设置。当然,这份名单是设置编过几个月的合并,所以我也欢迎被告知,我做错了什么。我没有过要显示的HTML内容的控制,但我试图尽可能广泛支持HTML5的一大片地。

With these settings, the WebView score 189 (w/ 1 bonus) on html5test.com. I am wondering if there are any settings that I should/could change to get further compatibility with HTML5. Of course, this list is an amalgamation of settings compiled over some months, so I'm also open to being told I'm doing something wrong. I do not have control over the html content to be displayed but am trying to support as broad a swath of HTML5 as possible.

推荐答案

我要补充:

    mWebView.setWebViewClient(new WebViewClient()); // tells page not to open links in android browser and instead open them in this webview