对话框中的Webview连续上下滚动

时间:2018-11-20 15:33:11

标签: android webview android-webview android-dialogfragment

我在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>

问题:问题是对话框不断向上和向下移动。如果我不调用webView.loadData方法,问题将消失。 而且,我第一次调用该对话框时,它仍然存在。第二次启动连续上升和下降。

为什么我遇到这个问题?我该怎么解决?

1 个答案:

答案 0 :(得分:1)

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

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