2

かなり大きなフォームを含むページをロードするWebビューを含むAndroidアプリを書いています。フォームの読み込み中に進行状況バーを表示します。プログレスバーが消えると、空白のページまたはフォームのいくつかの要素(チェックボックスのいくつか、テキストなしなど)のみが表示されることがよくあります。ページをスクロール(クリック)しようとすると、すべてが表示されます。ここで何が悪いのか考えていますか?

Webビューの設定は次のとおりです。

mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.getSettings().setDatabaseEnabled(true);
mWebView.getSettings().setDomStorageEnabled(true);
mWebView.getSettings().setAppCacheMaxSize(1024*1024*128);
mWebView.getSettings().setAppCachePath(getActivity().getApplicationContext().getCacheDir().getAbsolutePath());
mWebView.getSettings().setAllowFileAccess(true);
mWebView.getSettings().setAppCacheEnabled(true);
mWebView.getSettings().setCacheMode(WebSettings.LOAD_DEFAULT);
mWebView.setWebChromeClient(new WebChromeClient() {
       @Override
       public void onExceededDatabaseQuota(String url,
                            String databaseIdentifier,
                            long currentQuota,
                            long estimatedSize,
                            long totalUsedQuota,
                            WebStorage.QuotaUpdater quotaUpdater)
       {
           quotaUpdater.updateQuota(estimatedSize * 2);
       }
    });
mWebView.addJavascriptInterface(new WebFormJavascriptInterface(), "jsinterface");
mWebView.getSettings().setRenderPriority(RenderPriority.HIGH);
mWebView.getSettings().setPluginState(android.webkit.WebSettings.PluginState.ON_DEMAND);

レイアウトファイルは次のとおりです。

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<WebView  xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/webview"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:hardwareAccelerated="false"
    android:persistentDrawingCache="all"
/>
<ProgressBar
    android:id="@+id/progressbar"
    style="@android:style/Widget.Holo.ProgressBar.Large"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerHorizontal="true"
    android:layout_centerVertical="true"
    android:indeterminate="true"
    android:visibility="gone"/>
</RelativeLayout>
4

3 に答える 3

1

WebViewClient をオーバーライドしますか? super.onPageStarted() および super.onPageFinished() を削除して、WebViewClient の onPageStarted() および onPageFinished() メソッドをオーバーライドすると、同じ問題が発生します。WebView は最初に空白のページを読み込み、画面に触れるとコンテンツを表示します。私の問題を解決するスーパー(super.onPageStarted()、super.onPageFinished())のメソッドを返します。

于 2014-02-19T11:00:14.303 に答える