只需要在网页视图中禁用垂直滚动 android

Need to disable only vertical scrolling in web view android

在 XML 中,我将 android:scrollbars="none" 给了 web view

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

在java文件中,

wvProgress.setVerticalScrollBarEnabled(false);

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

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

首先,我设置了 webview 的高度和宽度,我required.Then将 webview 放在水平滚动视图中。所以,我发现垂直滚动被删除,只有水平滚动可用。 为了更好的UI性能和滚动,我在框架布局中放置了水平滚动视图。

我的源代码如下所示:-

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