Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android webview blinking once when loading data

I have text preloaded in a webview. When the data from the internet comes, I reload the webview with the new data.

The problem is the screen blinks once during the load data transition.

Any advice?

like image 448
Evan Lee Avatar asked Jan 14 '13 16:01

Evan Lee


2 Answers

Try to disable the hardware accelerator on the activity:

android:hardwareAccelerated="false"
like image 86
Pablo Avatar answered Sep 27 '22 19:09

Pablo


In your Activity

    LinearLayout.LayoutParams dfparams = new LinearLayout.LayoutParams(0,0, 0);
    wedview.setLayoutParams(dfparams);
    wedview.loadDataWithBaseURL(URL_SERVER, content, "text/html", "utf-8", null);

    wedview.setWebViewClient(new WebViewClient() {
        public void onPageFinished(WebView view, String url) {
            LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT, 0);
            wedview.setLayoutParams(params);

        }
    });

In Your layout.xml

    <LinearLayout
        android:id="@+id/llSearch"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:background="@null"
        android:orientation="vertical" >
    <WebView
            android:id="@+id/wvContent"
            android:layout_width="fill_parent"
            android:layout_height="0dp"
            android:scrollbars="none" />
 </LinearLayout>
like image 37
ngocquynh_183 Avatar answered Sep 27 '22 17:09

ngocquynh_183