【问题标题】:Need to disable only vertical scrolling in web view android只需要在 web 视图 android 中禁用垂直滚动
【发布时间】:2018-03-23 13:43:38
【问题描述】:

在 XML 中,我将 android:scrollbars="none" 赋予 Web 视图

<WebView
    android:id="@+id/wvProgress"
    android:layout_width="match_parent"
    android:scrollbars="none"
    android:layout_height="match_parent" />

在java文件中,

wvProgress.setVerticalScrollBarEnabled(false);

但是,仍然有一些垂直滚动条没有被禁用,并且在 Web 视图下方显示了一些额外的空白。

【问题讨论】:

  • 为什么要投反对票?请评论

标签: android webview vertical-scrolling


【解决方案1】:

在尝试了多种方法后,终于找到了解决问题的方法 - 在 webview 中只显示水平滚动并移除垂直滚动。

首先,我设置了我需要的 webview 的高度和宽度。然后将 webview 放入水平滚动视图中。所以,我发现垂直滚动被删除,只有水平滚动可用。 为了更好的 UI 性能和滚动,我将水平滚动视图放在 framelayout 中。

我的源代码如下所示:-

 <FrameLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent">

            <HorizontalScrollView
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:scrollbars="none">

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="match_parent">

                    <WebView
                        android:id="@+id/wvProgress"
                        android:minHeight="0dp"
                        android:layout_width="@dimen/_800dp"
                        android:layout_height="@dimen/_300dp" />
                </LinearLayout>
            </HorizontalScrollView>

        </FrameLayout>

【讨论】:

    猜你喜欢
    • 2014-06-12
    • 2012-12-12
    • 2020-11-14
    • 1970-01-01
    • 2014-05-20
    • 2013-07-18
    • 2011-07-27
    • 1970-01-01
    • 2019-03-07
    相关资源
    最近更新 更多