Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Strange webview black blinking when scrolling

I am loading the data from a String, and on the first time when I scroll down the webview blinks couple of times.

Here is my code where I load the data:

webview.loadDataWithBaseURL(null, message.getmContent(), "text/html", "UTF-8", null);

And the xml:

    <WebView
        android:id="@+id/web_content"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_above="@+id/footer"
        android:layout_below="@id/message_title"
        android:layout_margin="4dp"
         />
like image 584
user1940676 Avatar asked Jun 26 '13 09:06

user1940676


3 Answers

The solution is adding:

webview.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
webview.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
webview.getSettings().setRenderPriority(WebSettings.RenderPriority.HIGH);
like image 65
user1940676 Avatar answered Oct 23 '22 08:10

user1940676


It's also possible to set software layer type in xml file and it works fine for me.

android:layerType="software"
like image 42
Volodymyr Avatar answered Oct 23 '22 10:10

Volodymyr


After resolving with the above solution, My WebView autoFocused on scroll down. I resolved the flicker and auto-scroll by:

webView.setFocusable(false);
webView.setFocusableInTouchMode(false);
like image 1
Abhinav Saxena Avatar answered Oct 23 '22 10:10

Abhinav Saxena