【问题标题】:Android WebView content cuts off while continues zoom in/out (rendering issue)Android WebView 内容在继续放大/缩小时切断(呈现问题)
【发布时间】:2022-01-12 20:16:23
【问题描述】:

我想使用内置缩放功能在 WebView 中显示一些 HTML 内容。在某些情况下它非常好,但有时 HTML 内容在放大和缩小时会被截断。

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)

这是我的简单 XML 文件

<?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>

WebView 内容被截断时出现以下错误

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

【问题讨论】:

    标签: android html android-webview webviewchromium


    【解决方案1】:

    尝试添加settings.loadWithOverviewMode = truesettings.useWideViewPort = true

    【讨论】:

      猜你喜欢
      • 2014-09-18
      • 1970-01-01
      • 1970-01-01
      • 2013-03-20
      • 2011-11-18
      • 2013-11-17
      • 2012-09-09
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多