【问题标题】:Android - WebView inside ScrollView leave white space at the bottomAndroid - ScrollView 内的 WebView 在底部留下空白
【发布时间】:2013-04-21 05:20:28
【问题描述】:

我想在滚动容器中添加多个 WebView。为了做到这一点,我以编程方式将它们添加到 LinearLayout 中。

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
 android:id="@+id/scrollView"
 android:layout_width="fill_parent"
 android:layout_height="fill_parent">

 <LinearLayout
        android:id="@+id/webViewContainer"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical"
        />

 </ScrollView>

现在的问题是,当我使用 loadDataWithBaseURL() 方法在 WebViews 中加载数据时,WebViews 在底部留下了一些额外的空间。无法为这个问题找到合适的解决方案。谁能告诉我为什么会这样?

【问题讨论】:

  • 不需要将 webview 放在滚动视图下。只需一个按钮,然后单击加载带有 url 的 webview。使用一个 webview 进行活动。在适当的按钮单击时将 url 传递给活动,并将 url 加载到同一个 webview 中。用户不想长时间滚动查看数据。
  • 我的项目有这样的要求。除了上述问题之外,一切都像魅力一样工作。
  • 谁能帮我解决这个问题?
  • 也许这无济于事,但我在空白处也遇到了同样的问题,在我的情况下,如果我删除 ScrollView,webview 无法正常滚动,虽然没有空白,但应用程序可以不是滚动属性。我也在尝试在这里找到解决方案。坚持住。

标签: android android-webview android-scrollview


【解决方案1】:
WebView webView = new WebView(this);
        webView.loadDataWithBaseURL("about:blank",
                Utils.getHtmlData(article.getContent()), "text/html",
                "utf-8", null);
        rl_wrapper.removeAllViews();
        rl_wrapper.addView(webView);

我用一个包装器代替了webview,英语不是我的母语,但也希望它可以帮助你。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-01-11
    • 2016-05-08
    • 2018-12-07
    • 2015-12-20
    • 1970-01-01
    相关资源
    最近更新 更多