Android Question Webview CaptureBitmap not working with api 21+

fredo

Well-Known Member
Licensed User
An App of mine used the webview.CaptureBitmap method successful the last few years.
It worked as expected even with contents longer than the webviews height.

After changing the Manifest from "20" to
B4X:
android:targetSdkVersion="21"
the resulting Bitmap now has only the top visible part of the webview.

According to this and this the result of capturebitmap is different now due to performance reasons.

Is there something I can do to get the full webview content as a bitmap even with targetSdkVersion=21 and up?

 

fredo

Well-Known Member
Licensed User
Call this sub from Activity_Create (before you load the layout):
B4X:
Sub EnableSlowWebViewDocumentDraw
   Dim p As Phone
   If p.SdkVersion >= 21 Then
     Dim jo As JavaObject
     jo.InitializeStatic("android.webkit.WebView").RunMethod("enableSlowWholeDocumentDraw", Null)
   End If
End Sub

Thank you Erel!
It worked.
 
Upvote 0
Top