对话框中的 Webview 不断上下滚动

Webview in a dialog scrolls up and down continuously

我将 android webview 实现了一点 DialogFragment。我使用以下方法以编程方式设置了一些文本:webView.loadData(myString, "text/html", "utf-8");

我的xml布局:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@id/id_layout_list_dialog"
    style="@style/Window.Dialog"
    android:orientation="vertical">

    ...

    <WebView
        android:id="@+id/id_webview"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

   ...

</LinearLayout>

问题: 问题是Dialog不停的上下跳动。如果我不调用 webView.loadData 方法,问题就会消失。 而且,我第一次调用Dialog时,它还在。第二次开始就一直涨涨跌跌。

为什么我会遇到这个问题?我该如何解决?

好的,我解决了这个问题,只需将高度从 match_parent 更改为 wrap_content

<WebView
        android:id="@+id/id_webview"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />