javascript - 网页无法在 Android 应用内浏览器上正确加载

标签 javascript android webview google-chrome-app

我正在开发一个项目,需要在应用程序浏览器中打开另一个 Web 应用程序。为此,我在 Activity 中使用了 WebView,并将 Web 应用程序 URL 加载到其中。但它并没有像在 Chrome 浏览器中呈现那样呈现页面。 我已经搜索过并更新了 Activity 中的一些 WebView 设置,但仍然没有成功。 以下是设置: webView.getSettings().setJavaScriptEnabled(true);

    // Other webview options
    webView.getSettings().setLoadWithOverviewMode(true);
    webView.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
    webView.setScrollbarFadingEnabled(false);
    webView.getSettings().setPluginState(WebSettings.PluginState.ON);
    webView.getSettings().setAllowFileAccess(true);
  webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
    webView.getSettings().setDomStorageEnabled(true);
    webView.getSettings().setAppCacheEnabled(true);

除此之外我还需要添加更多设置吗?任何线索都将是可观的。

最佳答案

尝试使用viewport properties .

您可以使用 setUseWideViewPort() 启用宽视口(viewport)模式.

You can define properties of the viewport for your web page, such as the width and initial zoom level, using the <meta name="viewport" ...> tag in your document <head>.

检查这个tutorial以获得更多见解。

关于javascript - 网页无法在 Android 应用内浏览器上正确加载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47300406/

相关文章:

c# - 在 ASP.NET 网页中打开新选项卡

包内资源的 Android 路径

android - 如何通过 Android 模拟器在 Windows 中使用 telnet?

javascript - 启用 JavaScript 的 Flutter WebView

android - 让 Espresso 等待 WebView 完成加载

javascript - knockout - 使用 View 模型数据传递子数组

javascript - ReactJS 设置状态不会从 Axios 响应数据分配数组

javascript - 未捕获的类型错误 : Object has no method 'contains'

android - SHA1 证书指纹

c# - 滚动IOS时透明状态栏显示webview内容