WebView inside ViewPager or ScrollView - strange rendering error on Android 3.0+

I have a ViewPager. Each ViewPager page is a ScrollView. ScrollView contains a WebView and several other views.

On Android 2.3 and older, everything works fine, but in version 3.0+ there is a strange rendering problem:

The WebView should start right under the photo

When scrolling left / right in ViewPager, there is also a very subtle rendering problem (which is also present in the Android 4.0 Gmail app).

+8
android android-3.0-honeycomb webview hardware-acceleration
source share
3 answers

I partially solved it by calling webView.requestLayout() in ScrollView.onScrollChanged() . Now thatโ€™s almost normal, but when scrolling the WebView seems a little out of sync with the other ScrollView children Sometimes the WebView seems to scroll a bit slower than other views, and catch up with them in an instant.

+4
source share

This may be due to hardware acceleration. Try to specifically disable it. You can do it

1) in the application tag inside your manifest (which will disable hardware acceleration throughout the application)

 android:hardwareAccelerated="false" 

OR 2) Disable it for a problematic representation in the code:

 myView.setLayerType(View.LAYER_TYPE_SOFTWARE, null); 

For more information and to verify that WebView or ListView hardware acceleration is correct, see > this link

+12
source share

There was the same problem that was not fixed by the accepted answer. In the end, it turned out to be associated with position:fixed on the CSS page. Replacing these instances with position:absolute seemed to do the trick.

+2
source share

All Articles