The interface uses the WebView, and the webview inside has the picture to automatically switch causes the interface scroll bar to lag.

Source: Internet
Author: User

The most recent project is an interface made with WebView, but the horizontal scroll bar with the Android local animation effect is added to the top of the interface. When the picture inside the WebView is toggled, the scroll bar animation is stuck.

1:setlayertype (view.layer_type_software, NULL);

Regardless of whether hardware acceleration is turned on, there will be a bitmap (software layer) and soft rendering of webview on top.

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.

Advantages:

To animate, use software to draw a view tree only once, which is very provincial.

Do not use the view tree when it is updated frequently. Especially when hardware acceleration is turned on, each update consumes more time. Because after rendering this bitmap, it is necessary to render this bitmap to the hardware layer.

The above setting causes the scroll bar to stutter

2:webview.setlayertype (view.layer_type_hardware, NULL);

When hardware acceleration is off, the effect is the same as software.
Hardware acceleration is rendered on FBO (Framebuffer Object) when it is turned on, and the view tree only needs to be drawn once when animating.

The difference between the two:
1, one is rendered to bitmap, one is rendered to FB.
2, hardware may have some operations not supported.
The two are the same:
All open a buffer and draw the view to this buffer.

3:layer_type_none
This is relatively simple, do not create a separate layer for this view tree

The Ps:glsurfaceview and webview default Layertype are none.

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

The interface uses the WebView, and the webview inside has the picture to automatically switch causes the interface scroll bar to lag.

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.