Android WebView content cuts off while continues zoom in/out (rendering issue)

409 views Asked by At

I want to display some HTML content in WebView with built-in zoom functionality. It is perfectly fine for some of the cases but sometimes HTML content cuts off while zoom in and out.

val settings = webview.settings
settings.loadsImagesAutomatically = true
settings.javaScriptEnabled = true
settings.setSupportZoom(true)
settings.builtInZoomControls = true
settings.displayZoomControls = false
webview.loadDataWithBaseURL("file:///android_asset/", onlyHtmlString, "text/html", "utf-8", null)

Here is my simple XML file

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/relativeLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">
        
    <WebView
        android:id="@+id/webview"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

</RelativeLayout>

I'm getting below error while WebView content cuts off

I/chromium: [INFO:SkTypeface_remote.cpp(29)] GlyphCacheMiss generateMetrics: Rec
      textsize 162 prescale 1 preskew 0 post [1 0 0 1]
      frame -1 miter 0 format 1 join 0 cap 0 flags 0x3104
      lum bits ff000000, device gamma 64, paint gamma 64 contrast 0

enter image description here

1

There are 1 answers

0
Jakub Kostka On

Try adding settings.loadWithOverviewMode = true and settings.useWideViewPort = true.