【问题标题】:Android WebView Load site IssueAndroid WebView 加载站点问题
【发布时间】:2015-05-15 08:25:05
【问题描述】:

我有一个博客网站的 URL,我像这样从我的 Android 应用程序加载它

 webView = (WebView) findViewById(R.id.webview);
 webView.getSettings().setJavaScriptEnabled(true);
 webView.getSettings().setLoadWithOverviewMode(true);
 webView.getSettings().setUseWideViewPort(true);
 webView.loadUrl(myURL);
 webView.setWebViewClient(new CustomWebViewClient());

CustomWebViewClient 类

 private class CustomWebViewClient extends WebViewClient {

    @Override
    public void onPageStarted(WebView view, String url, Bitmap favicon) {
        super.onPageStarted(view, url, favicon);
        showProgressDialog(BrowserActivity.this);
    }

    @Override
    public void onPageFinished(WebView view, String url) {
        hideProgressDialog(BrowserActivity.this);
    }
}

网站加载并在 2 行上显示一些图像。如果我从手机浏览器打开博客并将页面滚动到最后,则会自动加载更多图像。所以问题是,如果从我的应用程序打开博客,它只显示 2 行,并且不会加载其余的图像。可能是什么问题?我该如何解决这个问题?

【问题讨论】:

  • 可能是博客页面的Ajax问题,看看stackoverflow.com/questions/14191338/…webView.getSettings().setAllowUniversalAccessFromFileURLs(true);
  • 这也不起作用。也许我这边无能为力。

标签: javascript android url webview


【解决方案1】:
 webview.getSettings().setLayoutAlgorithm(LayoutAlgorithm.SINGLE_COLUMN);

或在xml文件中使用

<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scrollbars="vertical"    >
  <WebView
    android:id="@+id/mywebview"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:scrollbars="none" />
</ScrollView>

在 Java 文件中

webview.setScrollContainer(false);

【讨论】:

    【解决方案2】:

    启用DOM storage 看看是否有帮助:

    webView.getSettings().setDomStorageEnabled(true);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-07-17
      • 1970-01-01
      • 1970-01-01
      • 2017-02-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多