WebView Flicker problem in Android

Source: Internet
Author: User

Source: http://blog.csdn.net/fhy_2008/article/details/7474330

Problem: WebView Loading page flashes

Cause: Turn on hardware acceleration

Solve:

Android WebView show Flash after 3.0+ to enable hardware acceleration, turn on hardware acceleration is added in manifest: android:hardwareaccelerated= "true"

However, after you turn on hardware acceleration, there may be a flicker problem with webview, and the workaround is to set it in WebView:

Setlayertype (view.layer_type_software, NULL);

This is the hardware acceleration shutdown in the webview. Setting Layer_type_software will convert the current view to bitmap save. This will not open multiple webview, otherwise it will be reported out of memory.

The workaround is to include the following in the WebView:

protected void onmeasure (int widthmeasurespec, int heightmeasurespec) {
Invalidate ();
Super.onmeasure (Widthmeasurespec, Heightmeasurespec);
}

2013 Update:

Recently, a problem has been found, after setting the background (black) for WebView, a black screen will be flashed on HTC One (4.0.3) and G20. As a result, the function of setting the background is changed.

SetBackgroundColor (Color.parsecolor ("#000000"))//ok will not flash black screen

SetBackgroundColor (0x000000);//Will flash black screen

WebView Flicker problem in Android

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.