首页 > 解决方案 > WebView 在 API 30 中不滚动

问题描述

我在 WebView 中有一个 html 文件,它只包含文本。它不是滚动 API 30 设备(模拟器)。但它正在滚动 api 30 以下的其他设备。

xml:

<WebView
        android:id="@+id/web_view"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" i tried match_parent and 0dp
        app:layout_constrainedHeight="true"
        android:layout_marginStart="@dimen/_20sdp"
        android:layout_marginTop="@dimen/_20sdp"
        android:layout_marginEnd="@dimen/_20sdp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintTop_toBottomOf="@id/divider" />

我也试过:

           android:scrollbars="vertical" (xml)
           webView.isVerticalScrollBarEnabled = true (programatic)

并尝试使用 FrameLayout 或 ScrollView,但仍然无法正常工作。顺便说一下,我加载了一个资产文件:

           webView.loadUrl("file:///android_asset/Agreement.html")

这是html文件的示例结构:

    <html>
    <head>
    <title>Agreement</title>
    </head>
    <body>
    <p>some texts... with <i> tag sometimes.... there are 2 paragraph </p>
    </html>

标签: androidhtmlandroid-layoutkotlinwebview

解决方案


推荐阅读